mirror of
https://github.com/bleak-ai/gcontext.git
synced 2026-08-11 13:19:23 +02:00
Anonymous install telemetry: POST /api/telemetry accepts install events from the CLI, GET /api/admin/installs lists them (auth-protected). Install model and installs table auto-created on startup. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
38 lines
872 B
Python
38 lines
872 B
Python
from contextlib import asynccontextmanager
|
|
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
from .db import init_db
|
|
from .routes_admin import router as admin_router
|
|
from .routes_public import router as public_router
|
|
from .routes_telemetry import router as telemetry_router
|
|
|
|
|
|
@asynccontextmanager
|
|
async def lifespan(app: FastAPI):
|
|
init_db()
|
|
yield
|
|
|
|
|
|
app = FastAPI(title="gcontext workflows API", lifespan=lifespan)
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=[
|
|
"https://gcontext.ai",
|
|
"https://www.gcontext.ai",
|
|
"http://localhost:3000",
|
|
"http://localhost:3001",
|
|
],
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
app.include_router(public_router)
|
|
app.include_router(admin_router)
|
|
app.include_router(telemetry_router)
|
|
|
|
|
|
@app.get("/health")
|
|
def health():
|
|
return {"status": "ok"}
|