Spaces:
Build error
Build error
# app.py - Entry point for Hugging Face Spaces | |
import os | |
import sys | |
import uvicorn | |
# Add the current directory to the path to ensure imports work correctly | |
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) | |
# Import the app from main.py | |
try: | |
from main import app | |
except ImportError as e: | |
print(f"Error importing app from main.py: {e}") | |
raise | |
# For Hugging Face Spaces | |
if __name__ == "__main__": | |
# Hugging Face Spaces uses port 7860 by default | |
port = int(os.environ.get("PORT", 7860)) | |
# Start the Uvicorn server with the FastHTML app | |
print(f"Starting Uvicorn server for Hugging Face Spaces on port {port}") | |
uvicorn.run( | |
app, | |
host="0.0.0.0", | |
port=port, | |
log_level="info" | |
) |