-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfetch_hf_status.py
More file actions
27 lines (24 loc) · 920 Bytes
/
Copy pathfetch_hf_status.py
File metadata and controls
27 lines (24 loc) · 920 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import requests
import os
import sys
def load_token():
if os.path.exists('.env'):
with open('.env', 'r') as f:
for line in f:
if line.startswith('HF_TOKEN='):
val = line.strip().split('=', 1)[1]
return val.strip('"').strip("'")
return os.environ.get('HF_TOKEN')
token = load_token()
headers = {"Authorization": "Bearer " + token}
for path in ["Dockerfile", "app.py", "requirements.txt", "start.sh", "start_web.py"]:
url = "https://huggingface.co/spaces/adityavanjre/project-k/raw/main/" + path
r = requests.get(url, headers=headers, timeout=10)
out = "=== " + path + " (status " + str(r.status_code) + ") ===\n"
if r.status_code == 200:
out += r.text[:3000]
else:
out += r.text[:200]
out += "\n"
sys.stdout.buffer.write(out.encode("utf-8", errors="replace"))
sys.stdout.buffer.flush()