Spaces:
Sleeping
Sleeping
| # api/main.py - MAIN FILE (Clean & Simple) | |
| from fastapi import FastAPI | |
| from fastapi.middleware.cors import CORSMiddleware | |
| from api.config import settings | |
| from api.utils import lifespan | |
| from api.routes import ( | |
| home_router, | |
| chat_router, | |
| sessions_router, | |
| health_router | |
| ) | |
| # Create FastAPI app | |
| app = FastAPI( | |
| title=settings.APP_TITLE, | |
| version=settings.APP_VERSION, | |
| description=settings.APP_DESCRIPTION, | |
| lifespan=lifespan | |
| ) | |
| # Add CORS middleware | |
| app.add_middleware( | |
| CORSMiddleware, | |
| allow_origins=settings.CORS_ORIGINS, | |
| allow_credentials=True, | |
| allow_methods=["*"], | |
| allow_headers=["*"], | |
| ) | |
| # Include routers | |
| app.include_router(home_router) | |
| app.include_router(chat_router) | |
| app.include_router(sessions_router) | |
| app.include_router(health_router) | |
| if __name__ == "__main__": | |
| import uvicorn | |
| uvicorn.run(app, host="0.0.0.0", port=7860) |