iaroy commited on
Commit
6e22e6b
·
1 Parent(s): 431f993

Add updated app.py with proper error handling for imports

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+ import os
3
+
4
+ # Add the current directory to the Python path
5
+ sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
6
+
7
+ # Import fastapi for fallback
8
+ import fastapi
9
+
10
+ # Try to import the main app
11
+ try:
12
+ from app.main import app
13
+ print("Successfully imported app from app.main")
14
+ except ImportError as e:
15
+ print(f"Error importing app: {e}")
16
+ # Create a fallback app
17
+ app = fastapi.FastAPI(title="Collinear API Fallback")
18
+
19
+ @app.get("/")
20
+ async def root():
21
+ return {
22
+ "message": "Fallback API is running",
23
+ "error": "Could not import main application. See logs for details."
24
+ }
25
+
26
+ if __name__ == "__main__":
27
+ import uvicorn
28
+ uvicorn.run("app:app", host="0.0.0.0", port=7860, reload=True)