Python 谷歌应用程序引擎webapp WSGIApplication中的正则表达式匹配

Python 谷歌应用程序引擎webapp WSGIApplication中的正则表达式匹配,python,google-app-engine,web-applications,Python,Google App Engine,Web Applications,嗨,一个相当简单的问题: application = webapp.WSGIApplication([ ('/result', Result), ('/result/', Result), 唯一的区别是尾随的“/” 我可以将两个url映射合并为一个吗?默认情况下,google应用程序引擎将识别/result/与/result相同,这样您就可以使用它了 application = webapp.WSGIApplication([ ('/result', Result), 您还可以为链接创建正则

嗨,一个相当简单的问题:

application = webapp.WSGIApplication([
('/result', Result),
('/result/', Result),
唯一的区别是尾随的“/”


我可以将两个url映射合并为一个吗?

默认情况下,google应用程序引擎将识别/result/与/result相同,这样您就可以使用它了

application = webapp.WSGIApplication([
('/result', Result),
您还可以为链接创建正则表达式,例如

application = webapp.WSGIApplication([
('/block/([0-9]+)/permissions', Result),

“/result/?”


问号使前面的字符可选。

出于搜索引擎优化的原因,通常最好选择一个URL进行处理,然后将另一个URL重定向到所选的URL。否则,搜索引擎将看到重复的内容。例如,类似这样的事情:

class RedirectHandler(webapp.RequestHandler):
    def get(self):
        self.redirect("/result/", True)

application = webapp.WSGIApplication([ 
    ('/result', RedirectHandler), 
    ('/result/', Result), 
    ...

我试试看。但是
/result/
/result
不一样。我使用的是
/result/
,当人们键入
/result
时,它就不起作用了。请尝试一下/result作为开始。这个答案是错误的。appengine不会对后面的斜杠(或缺少斜杠)施展任何魔法。@NickJohnson奇怪的是,我实际上使用appengine,但我对is没有任何问题,但不管怎样