""" MPR FastAPI Application """ import os import sys # Add project root to path sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) from contextlib import asynccontextmanager from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware from core.api.detect import router as detect_router @asynccontextmanager async def lifespan(app): from core.db.connection import create_tables from core.db.seed import seed_profiles create_tables() seed_profiles() yield app = FastAPI( title="MPR API", version="0.1.0", docs_url="/docs", redoc_url="/redoc", lifespan=lifespan, ) app.add_middleware( CORSMiddleware, allow_origins=["http://mpr.local.ar", "http://k8s.mpr.local.ar", "http://localhost:5173"], allow_credentials=True, allow_methods=["*"], allow_headers=["*"], ) # Detection API (sources, run, SSE, replay, config) app.include_router(detect_router) @app.get("/health") def health(): return {"status": "ok"} @app.get("/") def root(): return { "name": "MPR API", "version": "0.1.0", }