Skip to content

Instantly share code, notes, and snippets.

@Akash1362000
Created May 16, 2021 17:16
Show Gist options
  • Save Akash1362000/7b547e5e2283d88994b779f1c2585694 to your computer and use it in GitHub Desktop.
Save Akash1362000/7b547e5e2283d88994b779f1c2585694 to your computer and use it in GitHub Desktop.
Function Based Middleware in Django
def simple_middleware(get_response):
# One-time configuration and initialization.
def middleware(request):
# Code to be executed for each request before
# the view (and later middleware) are called.
response = get_response(request)
# Code to be executed for each request/response after
# the view is called.
return response
return middleware
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment