From 94392c2c997762d0b44c6ebdc5f1d9fc531cc873 Mon Sep 17 00:00:00 2001 From: Space-Banane Date: Wed, 20 May 2026 21:53:12 +0200 Subject: [PATCH] Add health and readiness endpoints --- backend/main.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/backend/main.py b/backend/main.py index 57f95ab..775ac51 100644 --- a/backend/main.py +++ b/backend/main.py @@ -28,6 +28,23 @@ app = FastAPI(title="Jellomator") app.add_middleware(CORSMiddleware, allow_origins=["*"], allow_credentials=True, allow_methods=["*"], allow_headers=["*"]) +@app.get("/healthz") +def healthz(): + return {"ok": True} + + +@app.get("/readyz") +def readyz(): + try: + with db() as c: + with c.cursor() as cur: + cur.execute("select 1 as ok") + cur.fetchone() + except Exception: + raise HTTPException(503, "Database not ready") + return {"ok": True} + + @contextmanager def db(): conn = pymysql.connect(