Skip to content

Instantly share code, notes, and snippets.

@Ivoz
Created March 11, 2013 22:38
Show Gist options
  • Save Ivoz/5138544 to your computer and use it in GitHub Desktop.
Save Ivoz/5138544 to your computer and use it in GitHub Desktop.
from gevent import wsgi
def simple_app(environ, start_response):
headers = [('Content-Type', 'text/plain')]
start_response('200 OK', headers)
def content():
# We start streaming data just fine.
yield 'The dwarves of yore made mighty spells,'
yield 'While hammers fell like ringing bells'
# Then the back-end fails!
try:
1/0
except:
start_response('500 Error', headers, sys.exc_info())
return
# So rest of the response data is not available.
yield 'In places deep, where dark things sleep,'
yield 'In hollow halls beneath the fells.'
return content()
server = wsgi.WSGIServer(('', 8000), simple_app)
server.serve_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment