File size: 759 Bytes
e83fac0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# 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"
    )