Add status URL

This commit is contained in:
Yehuda Deutsch 2023-05-16 23:06:02 -04:00
parent ac741dd071
commit 5fe9bd6f8b
Signed by: uda
GPG key ID: 8EF44B89374262A5
2 changed files with 14 additions and 1 deletions

View file

@ -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)

10
ajal_demo/views.py Normal file
View file

@ -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')