Is it possible to clone the flask.request object to use it later? I want to send the cloned request to another thread to repeat the same job. How can I put the cloned object on top of the request stack?
It is as simple as copying environ object. It has a copy() method that does the trick:
environ = flask.request.environ.copy()
Now you can use app.request_context to push a new context (with the cloned environ) to the flask context stack:
with app.request_context(environ):
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With