diff --git a/main.py b/main.py index 95966fb..38870d9 100644 --- a/main.py +++ b/main.py @@ -107,6 +107,17 @@ class ListWithItems(ListResponse): def read_root(): return {"message": "Shopping List API"} +@app.get("/health", tags=["meta"]) +def health_check(): + conn = get_db() + try: + conn.execute("SELECT 1").fetchone() + conn.close() + return {"status": "ok"} + except Exception as e: + conn.close() + return {"status": "error", "detail": str(e)}, 503 + @app.post("/products", response_model=ProductResponse, status_code=201, tags=["products"]) def create_product(product: Product): conn = get_db()