2011-03-27 61 views
0
('/\d+\?fmt=json',JsonHandler) 

class JsonHandler(webapp.RequestHandler): 
def get(self): 
    self.response.out.write("hello") 

嗨,我使用谷歌应用程序引擎python和tring将url映射到我的请求处理程序。 url是数字,后面跟着?fmt = json,但它不会打印出“hello”,正则表达式测试返回true,比如1234?fmt = json。任何帮助?谢谢为什么无法将网址映射到我的请求处理程序

+0

哇,今天的第二个问题试图将查询字符串包含在基于django的URL路由中。它不能做到。 – 2011-03-27 04:40:33

+0

@Josh这是web应用程序,而不是Django。 – 2011-03-28 02:30:52

+0

@Nick,它是基于django的谷歌应用程序引擎 - 这是我在我的评论(基于..)中所说的。 – 2011-03-28 02:52:07

回答

2

你不应该在正则表达式中包含查询参数。

('/\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")