Answers for "django simplest middleware"

0

django simplest middleware

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
Posted by: Guest on August-02-2021

Python Answers by Framework

Browse Popular Code Answers by Language