RedirectRoute + strict_slash = KeyError

时间:2013-06-06 04:32:11

标签: google-app-engine python-2.7 webapp2

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)

1 个答案:

答案 0 :(得分:0)

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