将所有url请求重定向到一个处理程序

时间:2011-12-08 23:07:24

标签: python google-app-engine

在使用google webapp框架的Google App Engine应用程序中,如何将每个请求重定向到一个处理程序?

检查此代码:

from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app

class MainPage(webapp.RequestHandler):
    def get(self):
        self.response.headers['Content-Type'] = 'text/plain'
        self.response.out.write('Hello, webapp World!')

application = webapp.WSGIApplication([('/', MainPage)],
                                     debug=True)

def main():
    run_wsgi_app(application)

if __name__ == "__main__":
    main()

如何更改application = webapp.WSGIApplication([('/', MainPage)], debug=True)行以重定向所有请求,而不是/。我尝试了*/*但它不起作用。

1 个答案:

答案 0 :(得分:5)

application = webapp.WSGIApplication([('/.*', MainPage)], ...

相关问题