From 4e6fbe0e95b7168ab641fd1726bc77383562e0ad Mon Sep 17 00:00:00 2001 From: Thephaseless Date: Mon, 21 Oct 2024 13:34:07 +0000 Subject: [PATCH] add healthcheck --- main.py | 12 ++++++++++++ tests/main_test.py | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/main.py b/main.py index e7d8e1b..84f5535 100644 --- a/main.py +++ b/main.py @@ -24,6 +24,18 @@ def read_root(): return RedirectResponse(url="/docs", status_code=301) +@app.get("/health") +async def health_check(): + """Health check endpoint.""" + logger.info("Health check") + browser = await new_browser() + await browser.grant_all_permissions() + page = await browser.get("https://google.com") + await page.bring_to_front() + browser.stop() + return {"status": "ok"} + + @app.post("/v1") async def read_item(request: LinkRequest): """Handle POST requests.""" diff --git a/tests/main_test.py b/tests/main_test.py index 4d160cc..2ad401a 100644 --- a/tests/main_test.py +++ b/tests/main_test.py @@ -35,3 +35,8 @@ def test_bypass(website: str): ) assert response.status_code == HTTPStatus.OK + + +def test_health_check(): + response = client.get("/health") + assert response.status_code == HTTPStatus.OK