Last active
March 10, 2020 16:48
-
-
Save dineshsprabu/ce6cddfbd6422a1704de7c250b0b0ef0 to your computer and use it in GitHub Desktop.
[Python][Tornado] Get all form submitted arguments and convert to dict
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Handler(tornado.web.RequestHandler): | |
def args_to_dict(self): | |
""" This method converts request arguments to | |
usable dict | |
""" | |
params = self.request.arguments | |
for k,v in params.items(): | |
params[k] = v[0].decode("utf-8") | |
return params | |
def post(self): | |
# This will return all arguments as dict. | |
self.request.arguments | |
# Decode the value of each key to str | |
# from byte. | |
self.request.arguments[key][0].decode('utf-8') | |
# Params as dict. | |
params_in_hash = self.args_to_dict() |
there is no method args_to_dict() on the RequestHandler
@javadba The method is defined in the user class Handler
inherited from RequestHandler
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
what version of Tornado? I just installed (2 yrs later) and there is no method args_to_dict() on the RequestHandler