9
WS 헤더 미들웨어 내에서 HTTP 헤더를 어떻게 추가 할 수 있습니까?WSGI 미들웨어에서 http 헤더를 추가하는 방법은 무엇입니까?
WS 헤더 미들웨어 내에서 HTTP 헤더를 어떻게 추가 할 수 있습니까?WSGI 미들웨어에서 http 헤더를 추가하는 방법은 무엇입니까?
나는 pylons book에서 멋진 예제를 발견했습니다.
class Middleware(object):
def __init__(self, app):
self.app = app
def __call__(self, environ, start_response):
def custom_start_response(status, headers, exc_info=None):
headers.append(('Set-Cookie', "name=value"))
return start_response(status, headers, exc_info)
return self.app(environ, custom_start_response)
트릭은 중첩 된 방법을 사용하는 것입니다.