From 3da4cfd3062973a7c2be1a544b16ac02b13ddd18 Mon Sep 17 00:00:00 2001 From: Brazing Technology Date: Wed, 29 Apr 2026 11:21:25 +0530 Subject: [PATCH] feat(backend): add /api/health endpoint for k8s readiness probe --- backend/app.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/backend/app.py b/backend/app.py index 8bf6059..556a25e 100644 --- a/backend/app.py +++ b/backend/app.py @@ -105,6 +105,20 @@ def delete_task(task_id): return jsonify({"result": "ok"}) +@app.route("/api/health", methods=["GET"]) +def health(): + try: + conn = get_db() + cur = conn.cursor() + cur.execute("SELECT 1") + cur.fetchone() + cur.close() + conn.close() + return jsonify({"status": "ok"}), 200 + except Exception as exc: + return jsonify({"status": "unhealthy", "error": str(exc)}), 503 + + if __name__ == "__main__": init_db() app.run(host="0.0.0.0", port=5000)