开发者

Difference between run_wsgi_app and wsgiref.handlers.CGIHandler

开发者 https://www.devze.com 2023-03-25 07:45 出处:网络
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'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?

0

精彩评论

暂无评论...
验证码 换一张
取 消