Question

I want pass one parameter in a Url (to update one of many paramaters contained by my URL) like this:

httpGet.setURI(new URI(url/user?"nickname"="John") 

ServerSide in Python:

class GetInfo(BaseHandler):
  def Get(self):
        nickname = self.get_argument("nickname")
        gender = self.get_argument("gender")
        logging.info(nickname)
        logging.info(gender)

  application = tornado.web.Application([
  (r"/", MainHandler),
  (r"/user", GetInfo),
  ])

The server told me that I can't do this because the parameter "gender" is missing. How can I do?

Thanks

Was it helpful?

Solution

First your URI seems to be wrong.

httpGet.setURI(new URI(url + "/user?nickname=John") 

And if you test from emulator to webserver and you use both on the same machine, use the IP address of the server instead of something like localhost or 127.0.0.1

Example:

String url = "http://192.168.1.104";
httpGet.setURI(new URI(url + "/user?nickname=John");

Edit: The answer to this OP is below:

it seems from the example at tornadoweb.org/documentation that you can set a default value. So you can try something like gender = self.get_argument("gender",None) . So gender should be set to None if you dont pass any gender parameter in the query string

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top