Saturday, May 7, 2016

get all POST args in python flask

http://stackoverflow.com/questions/25410944/print-all-post-request-parameters-without-knowing-their-names

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.
 
 

No comments:

Post a Comment