Spaces:
Sleeping
Sleeping
Commit ·
fbd137e
1
Parent(s): cff9165
Add Hugging Face config files to subfolder
Browse files468 unmodified lines469470471472473474475476477478468 unmodified linesif is_hf:print("偵測到為 Hugging Face Spaces 雲端環境,使用 Gradio 官方 launch() 啟動以相容 ZeroGPU 端口轉發與生命週期...")demo.launch(server_name="0.0.0.0",server_port=7860,prevent_thread_lock=False)else:import uvicorn468 unmodified lines469470471472473474475476477478479480481482483468 unmodified linesif is_hf:print("偵測到為 Hugging Face Spaces 雲端環境,使用 Gradio 官方 launch() 啟動以相容 ZeroGPU 端口轉發與生命週期...")# ⚠️ 必須將 ssr_mode 設為 False!# 在 Gradio 5/6 中,預設啟用的 SSR 模式會另外啟動一個 Node.js 代理伺服器來攔截請求,# 這會導致我們自訂的 FastAPI /docs、/predict、/train 等 API 端點被 Node.js 阻擋或劫持。# 關閉 ssr_mode 後,伺服器會由 Python 直接處理 7860 端口的所有流量,使 Swagger UI 與 API 順利開通。demo.launch(server_name="0.0.0.0",server_port=7860,prevent_thread_lock=False,ssr_mode=False)else:import uvicorn
app.py+6-1