0

http://mysite.com/cn - 好的

http://mysite.com/cn/ - 错误

KeyError:'缺少参数“0”来构建 URI。'

我只有一条路线。请帮忙...

class MyHome(webapp2.RequestHandler):
  def get(self, language='en'):
    buf = 'hello world at %s' % (language,)
    self.response.write(buf)

app = webapp2.WSGIApplication([
    routes.DomainRoute(r'<:(localhost|mysite\.com|www\.mysite\.com)>', [
      routes.RedirectRoute(r'/<:(en|bm|my|cn|zh)>', handler=MyHome, strict_slash=True,  name='Home'),
    ]),
], debug=True)
4

1 回答 1

0

我认为你想要r'/<language:...而不是r'/<:...你的路线

于 2013-06-12T23:10:18.790 回答