Is It Possible To Redirect Inside A Middleware Class?
class Middleware: def __init__(self, app): self.app = app def __call__(self, environ, start_response): request = Request(environ) cookies = reques
Solution 1:
Not sure. Because WSGI middleware is at a layer outside the app itself.
You can use other hooks to work inside app / request context. In this case you can use flask.request
, flask.redirect()
etc. By the way, you don't need to initialize the request (request = Request (Environment)
).
Post a Comment for "Is It Possible To Redirect Inside A Middleware Class?"