Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added backend/health/__init__.py
Empty file.
5 changes: 5 additions & 0 deletions backend/health/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class HealthConfig(AppConfig):
name = "health"
10 changes: 10 additions & 0 deletions backend/health/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from django.urls import path

from health.views import HealthView


app_name = "health"

urlpatterns = [
path("health/", HealthView.as_view(), name="health"),
]
25 changes: 25 additions & 0 deletions backend/health/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from http import HTTPStatus

from django.http import JsonResponse
from django.views.generic import View


class HealthView(View):
def get(self, request):
"""
Health check endpoint to confirm the backend is running.
---
summary: Health Check
responses:
"200":
content:
application/json:
schema:
type: object
properties:
message:
type: string
enum: ["OK"]
---
"""
return JsonResponse({"message": "OK"}, status=HTTPStatus.OK)
1 change: 1 addition & 0 deletions backend/pennmobile/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"options.apps.OptionsConfig",
"sublet",
"phonenumber_field",
"health",
]

MIDDLEWARE = [
Expand Down
1 change: 1 addition & 0 deletions backend/pennmobile/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
path("penndata/", include("penndata.urls")),
path("sublet/", include("sublet.urls")),
path("wrapped/", include("wrapped.urls")),
path("", include("health.urls")),
]

urlpatterns = [
Expand Down
Empty file.
8 changes: 8 additions & 0 deletions backend/tests/health/test_route.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.test import TestCase


class HealthTestCase(TestCase):
def test_health(self):
resp = self.client.get("/health/")
self.assertEqual(resp.status_code, 200)
self.assertEqual(resp.json(), {"message": "OK"})
Loading