I'm just learning how to use python and GAE and I've noticed that the main URL handler is shown in two different ways. What's the difference in calling run_wsgi_app vs wsgiref.handlers.CGIHandler? I've seen sample code shown i开发者_JAVA百科n both manner.
application = webapp.WSGIApplication(
[
('/', MainPage),
('/sign', Guestbook)
], debug = True)
wsgiref.handlers.CGIHandler().run(application)
vs
application = webapp.WSGIApplication(
[
('/', MainPage),
('/sign', Guestbook)
], debug = True)
def main():
run_wsgi_app(application)
run_wsgi_app
is the one you should be using. Amongst other things, it runs any middleware defined in appengine_config.py
. The CGIHandler
approach dates from before run_wsgi_app
was introduced. There shouldn't be any examples of this left in the docs - where did you find it?
精彩评论