2026-08-08 13:15:47 +02:00
|
|
|
from contextlib import asynccontextmanager
|
|
|
|
|
|
|
|
|
|
from fastapi import FastAPI
|
2026-08-09 02:17:41 +02:00
|
|
|
from fastapi.middleware.cors import CORSMiddleware
|
2026-08-08 13:15:47 +02:00
|
|
|
|
|
|
|
|
from .db import init_db
|
2026-08-09 02:17:41 +02:00
|
|
|
from .routes_admin import router as admin_router
|
2026-08-08 13:15:47 +02:00
|
|
|
from .routes_public import router as public_router
|
2026-08-11 11:23:52 +02:00
|
|
|
from .routes_telemetry import router as telemetry_router
|
2026-08-08 13:15:47 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@asynccontextmanager
|
|
|
|
|
async def lifespan(app: FastAPI):
|
|
|
|
|
init_db()
|
|
|
|
|
yield
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app = FastAPI(title="gcontext workflows API", lifespan=lifespan)
|
2026-08-09 02:17:41 +02:00
|
|
|
app.add_middleware(
|
|
|
|
|
CORSMiddleware,
|
|
|
|
|
allow_origins=[
|
|
|
|
|
"https://gcontext.ai",
|
|
|
|
|
"https://www.gcontext.ai",
|
|
|
|
|
"http://localhost:3000",
|
|
|
|
|
"http://localhost:3001",
|
|
|
|
|
],
|
|
|
|
|
allow_methods=["*"],
|
|
|
|
|
allow_headers=["*"],
|
|
|
|
|
)
|
2026-08-08 13:15:47 +02:00
|
|
|
app.include_router(public_router)
|
2026-08-09 02:17:41 +02:00
|
|
|
app.include_router(admin_router)
|
2026-08-11 11:23:52 +02:00
|
|
|
app.include_router(telemetry_router)
|
2026-08-08 13:15:47 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.get("/health")
|
|
|
|
|
def health():
|
|
|
|
|
return {"status": "ok"}
|