[英]GAE multiple WSGI files for multiple URL handlers
I'm having problems understanding how I would use Google App Engine URL handler mapping to map URLs to various files. 我在理解如何使用Google App Engine URL处理程序映射将URL映射到各种文件时遇到问题。 Here's the code I currently have:
这是我目前拥有的代码:
app.yaml 的app.yaml
handlers:
- url: /
script: main.app
- url: /blog/*
script: blog.app
end of main.py (MainPage handler does exist towards top) main.py的末尾 (MainPage处理程序确实存在于顶部)
app = webapp2.WSGIApplication([('/', MainPage)], debug=True)
end of blog.py (BlogPage and New Post exist towards top) blog.py的结尾 (BlogPage和New Post位于顶部)
app = webapp2.WSGIApplication([('/blog', BlogPage), ('/blog/newpost', NewPost)], debug=True)
So right now, if I go to http://127.0.0.1/
my MainPage handler will pick it up like it's supposed to. 因此,现在,如果我转到
http://127.0.0.1/
我的MainPage处理程序将按照预期的方式进行处理。 But, if I go to http://127.0.0.1/blog/
then I end up getting a 404. I can't figure out if it's the handler in my blog.py file that's messing up, or if I need to have the handlers defined in app.yaml changed. 但是,如果我转到
http://127.0.0.1/blog/
则最终得到404。我无法弄清楚是不是我的blog.py文件中的处理程序搞砸了,还是我需要app.yaml中定义的处理程序已更改。
Thanks much! 非常感谢!
There was no match for the URI you're requesting, ie /blob/. 您所请求的URI没有匹配项,即/ blob /。 Note that you have the extra '/' at the end.
请注意,您在末尾有额外的“ /”。 If you want that to be handled by BlogPage, you can use the following ...
如果希望由BlogPage处理,则可以使用以下方法...
app = webapp2.WSGIApplication([('/blog/?', BlogPage), ('/blog/newpost', NewPost)], debug=True)
/blog/? /博客/? will match either /blog or /blog/.
将匹配/ blog或/ blog /。
Hope that helps. 希望能有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.