diff --git a/ajal_demo/urls.py b/ajal_demo/urls.py index b4df777..2d655d7 100644 --- a/ajal_demo/urls.py +++ b/ajal_demo/urls.py @@ -17,8 +17,11 @@ Including another URLconf from django.conf import settings from django.conf.urls.static import static from django.contrib import admin -from django.urls import path +from django.urls import path, re_path + +from .views import status urlpatterns = [ path('admin/', admin.site.urls), + re_path('^status/?$', status), ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) diff --git a/ajal_demo/views.py b/ajal_demo/views.py new file mode 100644 index 0000000..f822021 --- /dev/null +++ b/ajal_demo/views.py @@ -0,0 +1,10 @@ +from django.http import HttpRequest, HttpResponse + + +def status(request: HttpRequest): + for accepted_type in request.accepted_types: + if accepted_type.is_all_types: + break + if accepted_type.match('application/json'): + return HttpResponse(b'{"status":"OK"}', content_type='application/json') + return HttpResponse('OK', content_type='text/plain')