Spaces:
Build error
Build error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# app.py - Entry point for Hugging Face Spaces
|
| 2 |
+
import os
|
| 3 |
+
import sys
|
| 4 |
+
import uvicorn
|
| 5 |
+
|
| 6 |
+
# Add the current directory to the path to ensure imports work correctly
|
| 7 |
+
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
| 8 |
+
|
| 9 |
+
# Import the app from main.py
|
| 10 |
+
try:
|
| 11 |
+
from main import app
|
| 12 |
+
except ImportError as e:
|
| 13 |
+
print(f"Error importing app from main.py: {e}")
|
| 14 |
+
raise
|
| 15 |
+
|
| 16 |
+
# For Hugging Face Spaces
|
| 17 |
+
if __name__ == "__main__":
|
| 18 |
+
# Hugging Face Spaces uses port 7860 by default
|
| 19 |
+
port = int(os.environ.get("PORT", 7860))
|
| 20 |
+
|
| 21 |
+
# Start the Uvicorn server with the FastHTML app
|
| 22 |
+
print(f"Starting Uvicorn server for Hugging Face Spaces on port {port}")
|
| 23 |
+
uvicorn.run(
|
| 24 |
+
app,
|
| 25 |
+
host="0.0.0.0",
|
| 26 |
+
port=port,
|
| 27 |
+
log_level="info"
|
| 28 |
+
)
|