24 lines
439 B
Python
24 lines
439 B
Python
from fastapi import FastAPI
|
|
|
|
app = FastAPI()
|
|
|
|
_healthy = True # DODANO
|
|
|
|
|
|
@app.get("/")
|
|
def root():
|
|
return {"message": "Pozdrav svijete"}
|
|
|
|
|
|
@app.get("/health")
|
|
def health():
|
|
if not _healthy: # DODANO
|
|
return {"status": "unhealthy"}
|
|
return {"status": "ok"}
|
|
|
|
|
|
@app.post("/break") # DODANO
|
|
def break_health():
|
|
global _healthy
|
|
_healthy = False
|
|
return {"message": "Servis je sada nezdrav — ocekuj restart"} |