Skip to content

Commit 1f5e5e7

Browse files
healthcheck (#122)
* Adds status code and removes header * Replaces status codes
1 parent 0715455 commit 1f5e5e7

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

api/healthcheck.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
from starlette.endpoints import HTTPEndpoint
22
from starlette.responses import PlainTextResponse
33
from submodules.model.business_objects import general
4+
from starlette import status
45

56

67
class Healthcheck(HTTPEndpoint):
78
def get(self, request) -> PlainTextResponse:
8-
headers = {"APP": "OK"}
9+
text = ""
10+
status_code = status.HTTP_200_OK
911
database_test = general.test_database_connection()
1012
if not database_test.get("success"):
11-
headers["DATABASE"] = database_test.get("error")
12-
return PlainTextResponse("OK", headers=headers)
13+
error_name = database_test.get("error")
14+
text += f"database_error:{error_name}:"
15+
status_code = status.HTTP_500_INTERNAL_SERVER_ERROR
16+
if not text:
17+
text = "OK"
18+
return PlainTextResponse(text, status_code=status_code)

0 commit comments

Comments
 (0)