2011-12-08 70 views
0

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

检查这个代码:

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)线到所有的请求重定向而不是只有/。我试过了,并且*/*它不起作用。

回答

5

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

+0

它的工作原理。谢谢! –

相关问题