1""" 2Simple WSGI applications for testing. 3""" 4 5from pprint import pformat 6 7try: 8 bytes 9except ImportError: 10 bytes = str 11 12 13def simple_app(environ, start_response): 14 """Simplest possible application object""" 15 status = '200 OK' 16 response_headers = [('Content-type', 'text/plain')] 17 start_response(status, response_headers) 18 return [b'WSGI intercept successful!\n'] 19 20 21def more_interesting_app(environ, start_response): 22 start_response('200 OK', [('Content-type', 'text/plain')]) 23 return [pformat(environ).encode('utf-8')] 24 25 26def post_status_headers_app(environ, start_response): 27 headers = [] 28 start_response('200 OK', headers) 29 headers.append(('Content-type', 'text/plain')) 30 return [b'WSGI intercept successful!\n'] 31 32 33def raises_app(environ, start_response): 34 raise TypeError("bah") 35 36 37def empty_string_app(environ, start_response): 38 start_response('200 OK', [('Content-type', 'text/plain')]) 39 return [b'', b'second'] 40 41 42def generator_app(environ, start_response): 43 start_response('200 OK', [('Content-type', 'text/plain')]) 44 yield b'First generated line\n' 45 yield b'Second generated line\n' 46