broadfield commited on
Commit
e0dc876
·
verified ·
1 Parent(s): e4b3a63

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -140,21 +140,22 @@ def build_space(repo_name,file_name,file_content,access_token=""):
140
  repo_id=repo_path,
141
  repo_type="space",
142
  space_sdk="gradio",
 
143
  private=False,
144
  )
145
  # Create a new Space
146
  #response = api.create_repo(repo_path)
147
- space_info = repo_url.json()
148
- print(space_info)
149
- space_id = space_info["name"]
150
- print(f"Created Space with ID: {space_id}")
151
  local_file_path=str(uuid.uuid4())
152
  with open(local_file_path, 'w') as f:
153
  f.write(str(file_content))
154
  f.close()
155
  # Upload a local file to the Space
156
  commit_message = "Adding file test: "+str(uuid.uuid4())
157
- client.upload_file(local_file_path, repo_id=space_id, path=file_name, commit_message=commit_message)
158
  print("File uploaded successfully.")
159
  # Commit changes
160
  commit_message += "\nInitial commit to the repository."+ local_file_path
 
140
  repo_id=repo_path,
141
  repo_type="space",
142
  space_sdk="gradio",
143
+ exist_ok=True,
144
  private=False,
145
  )
146
  # Create a new Space
147
  #response = api.create_repo(repo_path)
148
+ #space_info = repo_url.json()
149
+ #print(space_info)
150
+ #space_id = space_info["name"]
151
+ #print(f"Created Space with ID: {space_id}")
152
  local_file_path=str(uuid.uuid4())
153
  with open(local_file_path, 'w') as f:
154
  f.write(str(file_content))
155
  f.close()
156
  # Upload a local file to the Space
157
  commit_message = "Adding file test: "+str(uuid.uuid4())
158
+ client.upload_file(local_file_path, repo_id=repo_path, path=file_name, commit_message=commit_message)
159
  print("File uploaded successfully.")
160
  # Commit changes
161
  commit_message += "\nInitial commit to the repository."+ local_file_path