Files
zadaca/app/main.py
2026-05-04 18:32:59 +02:00

24 lines
512 B
Python

import os
from fastapi import FastAPI, Response, status
from fastapi.responses import JSONResponse
app = FastAPI()
_healthy = True
@app.get("/health")
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"}