MySafeCode commited on
Commit
0300076
·
verified ·
1 Parent(s): e8c0819

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -0
app.py CHANGED
@@ -10,6 +10,11 @@ def upload_file_to_hub(file_path, repo_id, path_in_repo, repo_type, commit_mess
10
  """
11
  Upload a single file to Hugging Face Hub
12
  """
 
 
 
 
 
13
  if not file_path:
14
  return "❌ Please select a file to upload"
15
 
@@ -37,6 +42,11 @@ def upload_folder_to_hub(folder_path, repo_id, folder_path_in_repo, repo_type,
37
  """
38
  Upload a folder to Hugging Face Hub
39
  """
 
 
 
 
 
40
  if not folder_path:
41
  return "❌ Please enter a folder path"
42
 
 
10
  """
11
  Upload a single file to Hugging Face Hub
12
  """
13
+ token = os.getenv("Key") # read secret inside the function
14
+ if not token:
15
+ raise RuntimeError("Missing Hugging Face secret 'Key'. Add it in your Space → Settings → Secrets.")
16
+
17
+ api = HfApi(token=token) # create api here
18
  if not file_path:
19
  return "❌ Please select a file to upload"
20
 
 
42
  """
43
  Upload a folder to Hugging Face Hub
44
  """
45
+ token = os.getenv("Key") # read secret inside the function
46
+ if not token:
47
+ raise RuntimeError("Missing Hugging Face secret 'Key'. Add it in your Space → Settings → Secrets.")
48
+
49
+ api = HfApi(token=token) # create api here
50
  if not folder_path:
51
  return "❌ Please enter a folder path"
52