Dan Holman
Dan Holman

Reputation: 835

Difference between run_wsgi_app and 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 in 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)

Upvotes: 4

Views: 978

Answers (1)

Nick Johnson
Nick Johnson

Reputation: 101149

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?

Upvotes: 3

Related Questions