Spaces:
Sleeping
Sleeping
Download app.py from Menixis/excel-viewer-test: direct link, hf CLI and curl.
- Browser
- Download file 923 Bytes
-
https://huggingface.co/spaces/Menixis/excel-viewer-test/resolve/main/app.py
- Command line
-
hf download hf://spaces/Menixis/excel-viewer-test/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Menixis/excel-viewer-test/resolve/main/app.py
923 Bytes
| import os | |
| import time | |
| from io import BytesIO | |
| import gradio as gr | |
| import pandas as pd | |
| import requests | |
| EXCEL_URL = os.environ.get("EXCEL_URL") | |
| def load_data(): | |
| if not EXCEL_URL: | |
| return pd.DataFrame({"error": ["EXCEL_URL secret is not set"]}) | |
| try: | |
| r = requests.get( | |
| f"{EXCEL_URL}&t={int(time.time())}", | |
| headers={"Cache-Control": "no-cache", "Pragma": "no-cache"}, | |
| timeout=30, | |
| ) | |
| r.raise_for_status() | |
| return pd.read_excel(BytesIO(r.content)) | |
| except Exception as e: | |
| return pd.DataFrame({"error": [str(e)]}) | |
| with gr.Blocks(title="Excel Viewer") as demo: | |
| gr.Markdown("# ๐ Excel Data Viewer") | |
| gr.Markdown("Data is pulled live from OneDrive. Click Refresh to re-fetch.") | |
| table = gr.Dataframe(value=load_data(), interactive=False, wrap=True) | |
| gr.Button("๐ Refresh").click(load_data, outputs=table) | |
| demo.launch() | |