How can I print all parameters that were passed in with a POST request using Python and flask?
I know how to ask for a parameter by name
from flask import request
key = request.args.get('key')
But i'm not sure why this did not work for me:
for a in request.args:
print "argument: " + a
request.args
returns a MultiDict
. It can have multiple values for each key. In order to print all parameters, you can try:
The code below works for URLs with parameters added,like:
http://www.webservice.my/rest?extraKey=extraValue
multi_dict = request.args
for key in multi_dict:
print multi_dict.get(key)
print multi_dict.getlist(key)
For parameters embedded within the POST request as a form:
dict = request.form
for key in dict:
print 'form key '+dict[key]
See the example here and you will have a good idea.
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