diff --git a/app/main.py b/app/main.py index 3f39a2b..6e55095 100644 --- a/app/main.py +++ b/app/main.py @@ -1,6 +1,6 @@ import os -import signal -from fastapi import FastAPI +from fastapi import FastAPI, Response, status +from fastapi.responses import JSONResponse app = FastAPI() _healthy = True @@ -9,13 +9,15 @@ _healthy = True @app.get("/health") def health(): if not _healthy: - return {"status": "unhealthy"}, 503 + return JSONResponse( + status_code=status.HTTP_503_SERVICE_UNAVAILABLE, + content={"status": "unhealthy"} + ) return {"status": "ok"} @app.post("/break") def break_health(): - """Simulira pad servisa za testiranje liveness probe-a""" global _healthy _healthy = False return {"message": "Servis je sada nezdrav — ocekuj restart"}