From 7a0bc997b960cd448b04f007a170a41d93b1ffde Mon Sep 17 00:00:00 2001 From: Maximilian Jugl Date: Thu, 22 Feb 2024 14:15:57 +0100 Subject: [PATCH] feat: add `/healthz` endpoint --- project/server.py | 6 ++++++ tests/test_health.py | 5 +++++ 2 files changed, 11 insertions(+) create mode 100644 tests/test_health.py diff --git a/project/server.py b/project/server.py index 8ff4fe6..ad36c28 100644 --- a/project/server.py +++ b/project/server.py @@ -25,6 +25,12 @@ async def lifespan(app: FastAPI): app = FastAPI(lifespan=lifespan) + +@app.get("/healthz") +async def do_healthcheck(): + return {"status": "ok"} + + app.include_router( upload.router, prefix="/upload", diff --git a/tests/test_health.py b/tests/test_health.py new file mode 100644 index 0000000..750dc7d --- /dev/null +++ b/tests/test_health.py @@ -0,0 +1,5 @@ +def test_200_healthcheck(test_client): + r = test_client.get("/healthz") + + assert r.status_code == 200 + assert r.json() == {"status": "ok"}