2016-09-28 55 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