Add status URL
This commit is contained in:
parent
ac741dd071
commit
5fe9bd6f8b
2 changed files with 14 additions and 1 deletions
|
|
@ -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
10
ajal_demo/views.py
Normal 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')
|
||||
Loading…
Add table
Reference in a new issue