I want to get the param of a url that is sent back to the server when the user submits the form. However I get this error AttributeError: 'HTTPServerRequest' object has no attribute 'get'
My url is http://127.0.0.1:8000/reset?key=0OeKkQcSRXiy6yAvtgd9GGv4DhO1t0EYuybjHG5Buzo=
The url string is created as:
keyVal=base64.b64encode(uuid.uuid4().bytes + uuid.uuid4().bytes)
emailLink = 'http://127.0.0.1:8000/reset?key=%s'%keyVal
The emailLink
is a used as a link.
I tried to retrieving the value of the param key
in the above url as:
class ResetPwdHandler(tornado.web.RequestHandler):
def get(self):
self.render("reset.html")
def post(self):
value = self.request.get('key')
print value
I receive the other form data fine, using self.get_argument()
, if I try to use it here then it says 'key' is missing argument.
I see examples that use urlparse
but how could you use this to get the param of the url when the form is submitted.
I've never used Tornado or its web framework, but the documentation is quite clear that the request class doesn't define a get
method. You are perhaps confusing it with Flask or webapp2. It seems like you can either do self.request.arguments['key']
or self.get_arguments('key')
.