diff --git a/main.py b/main.py index 7f2a202..a3befbd 100644 --- a/main.py +++ b/main.py @@ -1,17 +1,22 @@ from fastapi import FastAPI -import os, datetime +import os app = FastAPI() +_healthy = True @app.get("/health") def health(): - return { - "status": "ok", - "version": os.getenv("APP_VERSION", "dev"), - "timestamp": datetime.datetime.utcnow().isoformat() - } + if not _healthy: + return {"status": "unhealthy"}, 503 + 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"} @app.get("/") -def root(): - return {"poruka": "Zdravo s k3s!", "host": os.uname().nodename} - \ No newline at end of file +def read_root(): + return {"poruka": "Hello iz mog Docker containera!"}