Nav772 commited on
Commit
5cdade1
·
verified ·
1 Parent(s): ffaee22

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -1
app.py CHANGED
@@ -496,5 +496,16 @@ with gr.Blocks(title="Audio Language Translator") as demo:
496
  """)
497
 
498
  # Mount FastAPI to Gradio
 
 
 
 
 
 
 
499
  if __name__ == "__main__":
500
- demo.launch(server_name="0.0.0.0", server_port=7860)
 
 
 
 
 
496
  """)
497
 
498
  # Mount FastAPI to Gradio
499
+ # Mount Gradio onto FastAPI
500
+ app = gr.mount_gradio_app(api_app, demo, path="/")
501
+
502
+ # HuggingFace Spaces runs app.py directly, not via __main__
503
+ # So we need to use uvicorn for both local and HF deployment
504
+ import uvicorn
505
+
506
  if __name__ == "__main__":
507
+ uvicorn.run(app, host="0.0.0.0", port=7860)
508
+ else:
509
+ # For HuggingFace Spaces - it imports the app directly
510
+ # The 'app' variable is already set above
511
+ pass