Spaces:
Runtime error
Runtime error
Download src/backend/main.py from HAK-Tech/ciro-backend: direct link, hf CLI and curl.
- Browser
- Download file 2.04 kB
-
https://huggingface.co/spaces/HAK-Tech/ciro-backend/resolve/main/src/backend/main.py
- Command line
-
hf download hf://spaces/HAK-Tech/ciro-backend/src/backend/main.py
-
curl -L -o main.py https://huggingface.co/spaces/HAK-Tech/ciro-backend/resolve/main/src/backend/main.py
2.04 kB
| """ | |
| CIRO Backend β FastAPI Application Entry Point | |
| Run locally: | |
| uv run uvicorn backend.main:app --reload | |
| """ | |
| from contextlib import asynccontextmanager | |
| from fastapi import FastAPI | |
| from fastapi.middleware.cors import CORSMiddleware | |
| from backend.core.config import settings | |
| from backend.core.firebase import init_firebase | |
| from backend.routes import auth, crises, crisis, crowd_verification, report, trace, weather | |
| async def lifespan(app: FastAPI): | |
| init_firebase() | |
| yield | |
| app = FastAPI( | |
| title="CIRO Backend", | |
| description="Crisis Intelligence & Response Orchestrator β agentic AI backend", | |
| version="0.1.0", | |
| debug=settings.debug, | |
| lifespan=lifespan, | |
| redoc_url="/redoc", | |
| docs_url="/docs", | |
| ) | |
| # ββ CORS ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| app.add_middleware( | |
| CORSMiddleware, | |
| allow_origins=["*"], # Tighten in production | |
| allow_credentials=True, | |
| allow_methods=["*"], | |
| allow_headers=["*"], | |
| ) | |
| # ββ Routers βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| app.include_router(crises.router) | |
| app.include_router(crisis.router) | |
| app.include_router(trace.router) | |
| app.include_router(report.router) | |
| app.include_router(auth.router) | |
| app.include_router(weather.router) | |
| app.include_router(crowd_verification.router) | |
| # ββ Health Check ββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| async def root(): | |
| """Root endpoint β HF Spaces health-checks GET /.""" | |
| return {"status": "ok", "service": "ciro-backend"} | |
| async def health(): | |
| """Readiness probe for Cloud Run and local dev verification.""" | |
| return {"status": "ok"} | |