Spaces:
Sleeping
Sleeping
Commit
·
9473940
1
Parent(s):
57bfe5c
Fix runtime: mount FastAPI + use uvicorn for __main__; add uvicorn dep
Browse files- app.py +6 -2
- requirements.txt +1 -0
app.py
CHANGED
|
@@ -356,7 +356,11 @@ def _warmup_gpu():
|
|
| 356 |
return "ok"
|
| 357 |
|
| 358 |
if __name__ == "__main__":
|
| 359 |
-
# Local run. On Spaces, the platform
|
| 360 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 361 |
|
| 362 |
|
|
|
|
| 356 |
return "ok"
|
| 357 |
|
| 358 |
if __name__ == "__main__":
|
| 359 |
+
# Local run. On Spaces, the platform serves the FastAPI app automatically.
|
| 360 |
+
try:
|
| 361 |
+
import uvicorn
|
| 362 |
+
uvicorn.run(app, host="0.0.0.0", port=7860)
|
| 363 |
+
except Exception as e:
|
| 364 |
+
print("Failed to start uvicorn:", e)
|
| 365 |
|
| 366 |
|
requirements.txt
CHANGED
|
@@ -22,3 +22,4 @@ spaces>=0.28.3
|
|
| 22 |
dlib-binary
|
| 23 |
fastapi>=0.110
|
| 24 |
python-multipart>=0.0.9
|
|
|
|
|
|
| 22 |
dlib-binary
|
| 23 |
fastapi>=0.110
|
| 24 |
python-multipart>=0.0.9
|
| 25 |
+
uvicorn>=0.23
|