|
1 | | -import os |
2 | | -import sys |
3 | | -from pathlib import Path |
| 1 | +from fastapi import APIRouter |
4 | 2 |
|
5 | | -# Add the project root to Python path |
6 | | -project_root = Path(__file__).parent.parent |
7 | | -sys.path.insert(0, str(project_root)) |
| 3 | +router = APIRouter() |
8 | 4 |
|
9 | | -# Set environment variables for production |
10 | | -os.environ.setdefault("ENVIRONMENT", "production") |
11 | | -os.environ.setdefault( |
12 | | - "SECRET_KEY", os.environ.get("SECRET_KEY", "vercel-production-key-change-in-env") |
13 | | -) |
14 | | - |
15 | | -# Import the FastAPI app |
16 | | -from app.main import app |
17 | | - |
18 | | -# Vercel expects the app to be named 'app' |
19 | | -# If your FastAPI app is named differently, change this |
20 | | -app = app |
21 | | - |
22 | | - |
23 | | -# Optional: Add Vercel-specific middleware or configuration |
24 | | -@app.middleware("http") |
25 | | -async def add_vercel_headers(request, call_next): |
26 | | - response = await call_next(request) |
27 | | - response.headers["X-Vercel-Cache"] = "MISS" |
28 | | - return response |
29 | | - |
30 | | - |
31 | | -# Health check endpoint for Vercel |
32 | | -@app.get("/api/health") |
33 | | -async def health_check(): |
34 | | - return {"status": "healthy", "platform": "vercel", "app": "NeuroBank FastAPI"} |
35 | | - |
36 | | - |
37 | | -# For local development |
38 | | -if __name__ == "__main__": |
39 | | - import uvicorn |
40 | | - |
41 | | - uvicorn.run(app, host="0.0.0.0", port=int(os.environ.get("PORT", 8000))) |
| 5 | +@router.get("/") |
| 6 | +def root(): |
| 7 | + return {"status": "ok"} |
0 commit comments