I'm trying to make a usable tests for my package, but using Flask.test_client
is so different from the requests
API that I found it hard to use.
I have tried to make requests.adapters.HTTPAdapter
wrap the response, but it looks like werkzeug
doesn't use httplib
(or urllib
for that matter) to build it own Response
object.
Any idea how it can be done? Reference to existing code will be the best (googling werkzeug + requests doesn't give any useful results)
Many thanks!!
When the Flask application handles a request, it creates a Request object based on the environment it received from the WSGI server. Because a worker (thread, process, or coroutine depending on the server) handles only one request at a time, the request data can be considered global to that worker during that request.
Flask-Mime is Flask extension that enables applications to dispatch requests based on Accept header of it.
This payload can be in the shape of query strings, form data, and JSON objects. Flask, like any other web framework, allows you to access the request data. In this tutorial, you will build a Flask application with three routes that accept either query strings, form data, or JSON objects.
The flask object implements a WSGI application and acts as the central object. It is passed the name of the module or package of the application. Once it is created it will act as a central registry for the view functions, the URL rules, template configuration and much more.
A PyPI package now exists for this so you can use pip install requests-flask-adapter
.
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