Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import subprocess
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
# This script will run your FastAPI app using uvicorn
|
| 5 |
+
# It's important that uvicorn runs on 0.0.0.0 and the correct port
|
| 6 |
+
# HF Spaces often expose port 7860 for Python apps
|
| 7 |
+
port = os.getenv("PORT", "7860") # Use environment variable if set, otherwise default
|
| 8 |
+
command = f"uvicorn main:app --host 0.0.0.0 --port {port}"
|
| 9 |
+
subprocess.run(command, shell=True)
|