43 lines
691 B
Python
43 lines
691 B
Python
from fastapi import FastAPI
|
|
import platform
|
|
|
|
app = FastAPI()
|
|
|
|
_healthy = True
|
|
|
|
|
|
@app.get("/")
|
|
def root():
|
|
return {"poruka": "Hello iz mog Docker containera v2!"}
|
|
|
|
|
|
@app.get("/info")
|
|
def info():
|
|
return {
|
|
"python": platform.python_version(),
|
|
"verzija": "2.0"
|
|
}
|
|
|
|
|
|
@app.get("/health")
|
|
def health():
|
|
return {"status": "ok"}
|
|
|
|
|
|
@app.get("/live")
|
|
def live():
|
|
return {"status": "alive"}
|
|
|
|
|
|
@app.get("/ready")
|
|
def ready():
|
|
if not _healthy:
|
|
return {"status": "not ready"}
|
|
return {"status": "ready"}
|
|
|
|
|
|
@app.post("/break")
|
|
def break_health():
|
|
global _healthy
|
|
_healthy = False
|
|
return {"message": "Simuliran pad servisa (readiness će pasti)"} |