In the Flask documentation when testing ( http://flask.pocoo.org/docs/testing/ ), it has a line of code
rv = self.app.get('/')
And below he mentions "Using self.app.get, we can send an HTTP GET request to the application with the given path."
Where can I find documentation for these direct access methods (I assume there is one for all other methods)? In particular, I wonder what arguments they can take (for example, passing data, headers, etc.). Looking back at the flask documentation for the Flask object, it doesn't seem to list these methods, although it uses them in the example above.
Alternatively, a knowledgeable person may respond to what I am trying to understand: I am trying to simulate sending a POST request to my server, as with the following line, if I were to do this via HTTP:
res = requests.post("http://localhost:%d/generate" % port, data=json.dumps(payload), headers={"content-type": "application/json"})
This works when running the Flask application on the appropriate port. But I tried to replace it with the following:
res = self.app.post("/generate", data=json.dumps(payload), headers={"content-type": "application/json"})
And instead, the object I get in response is 400 BAD REQUEST .
source share