How do I make a trailing slash optional with webapp2?

后端 未结 9 819
感情败类
感情败类 2021-02-12 15:30

I\'m using the new webapp2 (now the default webapp in 1.6), and I haven\'t been able to figure out how to make the trailing slash optional in code like this:

web         


        
9条回答
  •  爱一瞬间的悲伤
    2021-02-12 16:09

    webapp2.Route template is not a regular expressions and your value is being escaped with re.escape. You can use old style rules which provides regular expression templates:

     webapp2.SimpleRoute('^/feed/?$', handler = feed)
    

提交回复
热议问题