2016-09-28 24 views
0

我正在運行以下代碼作爲我的GAE應用。Webapp2 Google應用引擎中的路由不工作

class HomeHandler(webapp2.RequestHandler): 
    def get(self): 
     self.response.write('This is the HomeHandler.') 

class ProductListHandler(webapp2.RequestHandler): 
    def get(self): 
     self.response.write('This is the ProductListHandler.') 

class ProductHandler(webapp2.RequestHandler): 
    def get(self, product_id): 
     self.response.write('This is the ProductHandler. ' 
      'The product id is %s' % product_id) 

app = webapp2.WSGIApplication([ 
    (r'/', HomeHandler), 
    (r'/products', ProductListHandler), 
    (r'/products/(\d+)', ProductHandler), 
]) 

當我嘗試訪問,只有「/」路線是工作(https://myapp.appspot.com)的版畫「這是HomeHandler」。如果我嘗試訪問https://myapp.appspot.com/products,我越來越

所請求的網址/產品此服務器

我是新來的服務器端開發上找到。我究竟做錯了什麼?

回答

3

很有可能您的app.yaml配置有誤。確保您的url部件中有.*

handlers: 
- url: .* 
    script: main.app