Madras1 commited on
Commit
e14e1b2
·
verified ·
1 Parent(s): aee5935

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -212,12 +212,19 @@ async def deploy_to_hf(request: HFDeployRequest):
212
  username = request.username or api.whoami()["name"]
213
  repo_id = f"{username}/{request.space_name}"
214
 
215
- # Create the static Space
 
 
 
 
 
 
 
216
  api.create_repo(
217
  repo_id=repo_id,
218
  repo_type="space",
219
  space_sdk="static",
220
- exist_ok=True # Don't error if exists
221
  )
222
 
223
  # Upload each file
 
212
  username = request.username or api.whoami()["name"]
213
  repo_id = f"{username}/{request.space_name}"
214
 
215
+ # Delete existing Space if it exists (to clean old files)
216
+ try:
217
+ api.delete_repo(repo_id=repo_id, repo_type="space")
218
+ print(f"Deleted existing Space: {repo_id}")
219
+ except Exception:
220
+ pass # Space doesn't exist, that's fine
221
+
222
+ # Create a fresh static Space
223
  api.create_repo(
224
  repo_id=repo_id,
225
  repo_type="space",
226
  space_sdk="static",
227
+ exist_ok=False # Should not exist since we just deleted it
228
  )
229
 
230
  # Upload each file