Spaces:
Runtime error
Runtime error
Simplify API structure using common FastAPI practices without __init__.py files
Browse files
app.py
DELETED
|
@@ -1,28 +0,0 @@
|
|
| 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)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|