1def simple_middleware(get_response):
2 # One-time configuration and initialization.
3
4 def middleware(request):
5 # Code to be executed for each request before
6 # the view (and later middleware) are called.
7
8 response = get_response(request)
9
10 # Code to be executed for each request/response after
11 # the view is called.
12
13 return response
14
15 return middleware
16