2011-03-27 62 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") 
相關問題