Skip to content

Commit

Permalink
Healthcheck (#22)
Browse files Browse the repository at this point in the history
* Adds status code and removes headers

* Replaces status codes
  • Loading branch information
SimonDegrafKern committed Mar 9, 2023
1 parent 82d52c2 commit a076199
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,13 @@ async def export_ws_stats(request: ExportWsStatsRequest) -> responses.PlainTextR

@app.get("/healthcheck")
def healthcheck() -> responses.PlainTextResponse:
headers = {"APP": "OK"}
text = ""
status_code = status.HTTP_200_OK
database_test = general.test_database_connection()
if not database_test.get("success"):
headers["DATABASE"] = database_test.get("error")
return responses.PlainTextResponse("OK", headers=headers)
error_name = database_test.get("error")
text += f"database_error:{error_name}:"
status_code = status.HTTP_500_INTERNAL_SERVER_ERROR
if not text:
text = "OK"
return responses.PlainTextResponse(text, status_code=status_code)

0 comments on commit a076199

Please sign in to comment.