Spaces:
Sleeping
Sleeping
| """FinSight AI — FastAPI backend (optional API; primary UI is Gradio).""" | |
| import logging | |
| from contextlib import asynccontextmanager | |
| from fastapi import FastAPI | |
| from fastapi.middleware.cors import CORSMiddleware | |
| from core.bootstrap import init_services, shutdown_services | |
| from routers import chat, documents, entities, ocr, sessions, summarize | |
| logging.basicConfig(level=logging.INFO) | |
| logger = logging.getLogger(__name__) | |
| async def lifespan(app: FastAPI): | |
| init_services() | |
| yield | |
| shutdown_services() | |
| app = FastAPI(title="FinSight AI", version="1.0.0", lifespan=lifespan) | |
| app.add_middleware( | |
| CORSMiddleware, | |
| allow_origins=[ | |
| "http://localhost:5173", | |
| "http://localhost:7860", | |
| "http://127.0.0.1:7860", | |
| ], | |
| allow_credentials=True, | |
| allow_methods=["*"], | |
| allow_headers=["*"], | |
| ) | |
| app.include_router(chat.router) | |
| app.include_router(documents.router) | |
| app.include_router(summarize.router) | |
| app.include_router(ocr.router) | |
| app.include_router(entities.router) | |
| app.include_router(sessions.router) | |
| async def health(): | |
| return {"status": "ok"} | |