import os from fastapi import FastAPI, Response, status from fastapi.responses import JSONResponse app = FastAPI() _healthy = True @app.get("/health") async def health(): if not _healthy: return JSONResponse( status_code=status.HTTP_503_SERVICE_UNAVAILABLE, content={"status": "unhealthy"} ) return {"status": "ok"} @app.post("/break") def break_health(): global _healthy _healthy = False return {"message": "Servis je sada nezdrav — ocekuj restart"}