-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathquick_upload.py
More file actions
24 lines (21 loc) · 611 Bytes
/
Copy pathquick_upload.py
File metadata and controls
24 lines (21 loc) · 611 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
import os
from huggingface_hub import HfApi
def load_token():
if os.path.exists('.env'):
with open('.env', 'r') as f:
for line in f:
if line.startswith('HF_TOKEN='):
return line.strip().split('=', 1)[1].strip('"\'')
return os.environ.get('HF_TOKEN')
token = load_token()
api = HfApi(token=token)
try:
api.upload_file(
path_or_fileobj='start_web.py',
path_in_repo='start_web.py',
repo_id='adityavanjre/project-k',
repo_type='space'
)
print('SUCCESS')
except Exception as e:
print('FAIL:', str(e))