Created
March 11, 2013 22:38
-
-
Save Ivoz/5138544 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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