I'm creating a stupid endpoint which just logs the posted data.
@app.route("/add_foo", methods=['POST'])
def add_foo():
logger.debug(request.data)
print(request.args.get('foo'))
return "Success"
I then attempt to post data to this endpoint:
>>> import requests
>>> r = requests.post("http://127.0.0.1:8080/add_foo", data={'foo': 'foobar'})
And I see the following output:
* Running on http://127.0.0.1:8080/ (Press CTRL+C to quit)
2016-07-28 08:59:22,432 - __main__ - DEBUG - b''
None
127.0.0.1 - - [28/Jul/2016 08:59:22] "POST /add_foo HTTP/1.1" 200 -
Interestingly, when I post the data through curl, I see the same thing. Here's my curl command:
curl -XPOST -d "{'foo': 'foobar'}" "http://localhost:8080/add_foo"
What is wrong with the data being posted?