MichaelChou0806 commited on
Commit
9d6b842
·
verified ·
1 Parent(s): ec44521

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -255,11 +255,12 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
255
  # ======================================================
256
  # 🚀 啟動(自動偵測:HF / 本地)
257
  # ======================================================
258
- # Hugging Face 會自動啟動,不需再執行 uvicorn
259
- if os.getenv("SPACE_ID"): # HF 上運行時會自動設此變數
260
- gr.mount_gradio_app(app, demo, path="/")
261
  else:
262
- # 本地測試用
263
- gr.mount_gradio_app(app, demo, path="/")
264
  import uvicorn
265
  uvicorn.run(app, host="0.0.0.0", port=7860)
 
 
255
  # ======================================================
256
  # 🚀 啟動(自動偵測:HF / 本地)
257
  # ======================================================
258
+ if os.getenv("SPACE_ID"):
259
+ # Hugging Face 環境(自動啟動)
260
+ app = gr.mount_gradio_app(app, demo, path="/")
261
  else:
262
+ # ✅ 本地測試環境(需手動啟動 uvicorn)
263
+ app = gr.mount_gradio_app(app, demo, path="/")
264
  import uvicorn
265
  uvicorn.run(app, host="0.0.0.0", port=7860)
266
+