assafvayner HF Staff Claude Sonnet 4.5 commited on
Commit
3ff68b3
·
1 Parent(s): df20a13

Fix app serving for HuggingFace Spaces

Browse files

Remove manual uvicorn.run() call and let Spaces handle app serving automatically. This fixes the 404 errors and malformed asset URLs.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

Files changed (1) hide show
  1. app.py +12 -18
app.py CHANGED
@@ -264,23 +264,17 @@ async def health_check():
264
  }
265
 
266
 
 
 
 
 
 
 
 
 
 
 
 
267
  # Mount Gradio app on FastAPI
 
268
  app = gr.mount_gradio_app(app, demo, path="/")
269
-
270
-
271
- if __name__ == "__main__":
272
- import uvicorn
273
-
274
- # Ensure dataset repo exists
275
- try:
276
- hf_api.create_repo(
277
- repo_id=DATASET_REPO,
278
- repo_type="dataset",
279
- exist_ok=True
280
- )
281
- print(f"✅ Dataset repository ready: {DATASET_REPO}")
282
- except Exception as e:
283
- print(f"⚠️ Warning: Could not create/verify dataset repo: {str(e)}")
284
-
285
- # Launch FastAPI app with uvicorn
286
- uvicorn.run(app, host="0.0.0.0", port=7860)
 
264
  }
265
 
266
 
267
+ # Ensure dataset repo exists on startup
268
+ try:
269
+ hf_api.create_repo(
270
+ repo_id=DATASET_REPO,
271
+ repo_type="dataset",
272
+ exist_ok=True
273
+ )
274
+ print(f"✅ Dataset repository ready: {DATASET_REPO}")
275
+ except Exception as e:
276
+ print(f"⚠️ Warning: Could not create/verify dataset repo: {str(e)}")
277
+
278
  # Mount Gradio app on FastAPI
279
+ # HuggingFace Spaces will automatically serve this app
280
  app = gr.mount_gradio_app(app, demo, path="/")