lyimo commited on
Commit
e83fac0
·
verified ·
1 Parent(s): 0762b9c

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
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
+ )