Skip to content

Commit 5a688dc

Browse files
Healthcheck (#35)
* Removes header * Adds status code * Replaces status code
1 parent 64cdaec commit 5a688dc

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
@@ -137,8 +137,13 @@ def config_changed() -> responses.PlainTextResponse:
137137

138138
@app.get("/healthcheck")
139139
def healthcheck() -> responses.PlainTextResponse:
140-
headers = {"APP": "OK"}
140+
text = ""
141+
status_code = status.HTTP_200_OK
141142
database_test = general.test_database_connection()
142143
if not database_test.get("success"):
143-
headers["DATABASE"] = database_test.get("error")
144-
return responses.PlainTextResponse("OK", headers=headers)
144+
error_name = database_test.get("error")
145+
text += f"database_error:{error_name}:"
146+
status_code = status.HTTP_500_INTERNAL_SERVER_ERROR
147+
if not text:
148+
text = "OK"
149+
return responses.PlainTextResponse(text, status_code=status_code)

0 commit comments

Comments
 (0)