Menixis commited on
Commit
8d8a7e9
Β·
verified Β·
1 Parent(s): 0facc82

Upload 3 files

Browse files
Files changed (3) hide show
  1. README.md +4 -8
  2. app.py +27 -0
  3. requirements.txt +4 -0
README.md CHANGED
@@ -1,14 +1,10 @@
1
  ---
2
- title: Excel Viewer Test
3
- emoji: πŸ‘
4
- colorFrom: green
5
- colorTo: pink
6
  sdk: gradio
7
- sdk_version: 6.14.0
8
- python_version: '3.13'
9
  app_file: app.py
10
  pinned: false
11
- license: mit
12
  ---
13
 
14
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: Excel Viewer
3
+ emoji: πŸ“Š
 
 
4
  sdk: gradio
5
+ sdk_version: 4.44.0
 
6
  app_file: app.py
7
  pinned: false
 
8
  ---
9
 
10
+ Test app that reads an Excel file from OneDrive.
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import time
3
+ from io import BytesIO
4
+
5
+ import gradio as gr
6
+ import pandas as pd
7
+ import requests
8
+
9
+ EXCEL_URL = os.environ.get("EXCEL_URL")
10
+
11
+ def load_data():
12
+ if not EXCEL_URL:
13
+ return pd.DataFrame({"error": ["EXCEL_URL secret is not set"]})
14
+ try:
15
+ r = requests.get(f"{EXCEL_URL}&t={int(time.time())}", timeout=30)
16
+ r.raise_for_status()
17
+ return pd.read_excel(BytesIO(r.content))
18
+ except Exception as e:
19
+ return pd.DataFrame({"error": [str(e)]})
20
+
21
+ with gr.Blocks(title="Excel Viewer") as demo:
22
+ gr.Markdown("# πŸ“Š Excel Data Viewer")
23
+ gr.Markdown("Data is pulled live from OneDrive. Click Refresh to re-fetch.")
24
+ table = gr.Dataframe(value=load_data(), interactive=False, wrap=True)
25
+ gr.Button("πŸ”„ Refresh").click(load_data, outputs=table)
26
+
27
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ gradio==4.44.0
2
+ pandas
3
+ openpyxl
4
+ requests