Skip to content

Commit a076199

Browse files
Healthcheck (#22)
* Adds status code and removes headers * Replaces status codes
1 parent 82d52c2 commit a076199

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

app.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,13 @@ async def export_ws_stats(request: ExportWsStatsRequest) -> responses.PlainTextR
9191

9292
@app.get("/healthcheck")
9393
def healthcheck() -> responses.PlainTextResponse:
94-
headers = {"APP": "OK"}
94+
text = ""
95+
status_code = status.HTTP_200_OK
9596
database_test = general.test_database_connection()
9697
if not database_test.get("success"):
97-
headers["DATABASE"] = database_test.get("error")
98-
return responses.PlainTextResponse("OK", headers=headers)
98+
error_name = database_test.get("error")
99+
text += f"database_error:{error_name}:"
100+
status_code = status.HTTP_500_INTERNAL_SERVER_ERROR
101+
if not text:
102+
text = "OK"
103+
return responses.PlainTextResponse(text, status_code=status_code)

0 commit comments

Comments
 (0)