From 34e0fa8d7144e0d7af5cb738671fc716ac09536b Mon Sep 17 00:00:00 2001 From: Flook Date: Sun, 26 Apr 2026 14:23:13 +0700 Subject: [PATCH] chore: add health-check api endpoint --- apps/common/urls.py | 7 +++++++ apps/common/views.py | 16 ++++++++++++++-- core/urls.py | 3 ++- 3 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 apps/common/urls.py diff --git a/apps/common/urls.py b/apps/common/urls.py new file mode 100644 index 0000000..ea92e29 --- /dev/null +++ b/apps/common/urls.py @@ -0,0 +1,7 @@ +from django.urls import path + +from apps.common.views import HealthCheckView + +urlpatterns = [ + path("health/", HealthCheckView.as_view(), name="health-check"), +] \ No newline at end of file diff --git a/apps/common/views.py b/apps/common/views.py index 91ea44a..ccae935 100644 --- a/apps/common/views.py +++ b/apps/common/views.py @@ -1,3 +1,15 @@ -from django.shortcuts import render +from rest_framework import status +from rest_framework.response import Response +from rest_framework.views import APIView -# Create your views here. + +class HealthCheckView(APIView): + permission_classes = [] + authentication_classes = [] + + def get(self, request): + return Response({ + 'status': 'ok', + 'service': 'lms-backend' + }, + status=status.HTTP_200_OK) \ No newline at end of file diff --git a/core/urls.py b/core/urls.py index 3667112..2b17726 100644 --- a/core/urls.py +++ b/core/urls.py @@ -15,8 +15,9 @@ Including another URLconf 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin -from django.urls import path +from django.urls import path, include urlpatterns = [ path('admin/', admin.site.urls), + path('', include('apps.common.urls')), ]