24 lines
515 B
Python
24 lines
515 B
Python
# main.py
|
|
from fastapi import FastAPI
|
|
import os, datetime
|
|
|
|
app = FastAPI()
|
|
_healthy = True
|
|
|
|
@app.get("/health")
|
|
def health():
|
|
if not _healthy:
|
|
return {"status": "unhealthy"}, 503
|
|
return {"status": "ok"}
|
|
|
|
@app.get("/")
|
|
def root():
|
|
return {"message":"Hello iz mog Docker containere"}
|
|
|
|
@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"}
|