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

Ric*_*olo 0 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()
Run Code Online (Sandbox Code Playgroud)

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

Dav*_*ith 5

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