init: hello-cicd projectsetup
This commit is contained in:
23
main.py
23
main.py
@@ -1,22 +1,17 @@
|
||||
from fastapi import FastAPI
|
||||
import os
|
||||
import os, datetime
|
||||
|
||||
app = FastAPI()
|
||||
_healthy = True
|
||||
|
||||
@app.get("/health")
|
||||
def health():
|
||||
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"}
|
||||
return {
|
||||
"status": "ok",
|
||||
"version": os.getenv("APP_VERSION", "dev"),
|
||||
"timestamp": datetime.datetime.utcnow().isoformat()
|
||||
}
|
||||
|
||||
@app.get("/")
|
||||
def read_root():
|
||||
return {"poruka": "Hello iz mog Docker containera!"}
|
||||
def root():
|
||||
return {"poruka": "Zdravo s k3s!", "host": os.uname().nodename}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user