def chunked_fail_app(environ, start_response):
"""http://rhodesmill.org/brandon/2013/chunked-wsgi/
"""
headers = [('Content-Type', 'text/plain')]
start_response('200 OK', headers)
# We start streaming data just fine.
yield b"The dwarves of yore made mighty spells,"
yield b"While hammers fell like ringing bells"
# Then the back-end fails!
try:
1 / 0
except Exception:
start_response('500 Error', headers, sys.exc_info())
return
# So rest of the response data is not available.
yield b"In places deep, where dark things sleep,"
yield b"In hollow halls beneath the fells."
评论列表
文章目录