DaveM2430 commited on
Commit
619861f
·
verified ·
1 Parent(s): 4835376

Update streamlit_app.py

Browse files
Files changed (1) hide show
  1. streamlit_app.py +5 -17
streamlit_app.py CHANGED
@@ -4,22 +4,10 @@ import requests
4
  token = os.environ.get("MAC_TOKEN", "")
5
  repo = "BrewsterWhitecapsMAC/mac-private"
6
 
7
- def download_private_file(repo_id, filename, token, dest=None):
8
- if dest is None:
9
- dest = f"/tmp/{filename}"
10
- url = f"https://huggingface.co/datasets/{repo_id}/resolve/main/{filename}"
11
- resp = requests.get(url, headers={"Authorization": f"Bearer {token}"}, timeout=60)
12
- if resp.status_code != 200:
13
- raise Exception(f"Failed to download {filename}: {resp.status_code}")
14
- with open(dest, "wb") as f:
15
- f.write(resp.content)
16
- return dest
17
-
18
- # Download app code
19
- download_private_file(repo, "mac_app.py", token, dest="/tmp/mac_app.py")
20
-
21
- # Download parquet data
22
- download_private_file(repo, "AllCollege_RE288.parquet", token,
23
- dest="/tmp/AllCollege_RE288.parquet")
24
 
25
  exec(open("/tmp/mac_app.py").read())
 
4
  token = os.environ.get("MAC_TOKEN", "")
5
  repo = "BrewsterWhitecapsMAC/mac-private"
6
 
7
+ # Always fetch latest app code
8
+ url = f"https://huggingface.co/datasets/{repo}/resolve/main/mac_app.py"
9
+ resp = requests.get(url, headers={"Authorization": f"Bearer {token}"}, timeout=60)
10
+ with open("/tmp/mac_app.py", "wb") as f:
11
+ f.write(resp.content)
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
  exec(open("/tmp/mac_app.py").read())