Skip to content

Instantly share code, notes, and snippets.

@mgax
Created December 29, 2020 10:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mgax/cf771b1991e68ca454693d5f3597ff04 to your computer and use it in GitHub Desktop.
Save mgax/cf771b1991e68ca454693d5f3597ff04 to your computer and use it in GitHub Desktop.
Health check with no HTTP Host header
from django.http import HttpResponse
def health(get_response):
def middleware(request):
if request.path == "/health":
return HttpResponse("Healthy")
return get_response(request)
return middleware
MIDDLEWARE = [
'myapp.middleware.health',
# 'django.middleware.security.SecurityMiddleware',
# other middleware
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment