Create streamlit_app.py
Browse files- streamlit_app.py +20 -0
streamlit_app.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import requests
|
| 3 |
+
|
| 4 |
+
token = os.environ.get("HITTER_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_private_file(repo, "mac_app.py", token, dest="/tmp/mac_app.py")
|
| 19 |
+
|
| 20 |
+
exec(open("/tmp/mac_app.py").read())
|