Update app.py
Browse files
app.py
CHANGED
|
@@ -255,11 +255,12 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 255 |
# ======================================================
|
| 256 |
# 🚀 啟動(自動偵測:HF / 本地)
|
| 257 |
# ======================================================
|
| 258 |
-
|
| 259 |
-
|
| 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 |
+
|