开发者

Why cant map the url to my request handler

开发者 https://www.devze.com 2023-02-20 13:52 出处:网络
(\'/\\d+\\?fmt=json\',JsonHandler) class JsonHandler(webapp.RequestHandler): def get(self): self.response.out.write(\"hello\"开发者_运维技巧)
('/\d+\?fmt=json',JsonHandler)

class JsonHandler(webapp.RequestHandler):
def get(self):
    self.response.out.write("hello"开发者_运维技巧)

Hey, I am using google app engine python and tring to map the url to my request handler. The url is digits followed by ?fmt=json, but it just doesnt print out "hello" and the regex test returns true, say 1234?fmt=json. any help? thank you


You shouldn't include the query parameter in the regex.

('/\d+',JsonHandler)

class JsonHandler(webapp.RequestHandler): 
  def get(self):
    if self.request.get("fmt") == "json": #check the query string in the get handler
      self.response.out.write("hello")
0

精彩评论

暂无评论...
验证码 换一张
取 消