WSGI Helpers
The following classes and functions are designed to make working with the WSGI specification easier or operate on the WSGI layer. All the functionality from this module is available on the high-level Request/Response classes.
Iterator / Stream Helpers
These classes and functions simplify working with the WSGI application iterator and the input stream.
- class werkzeug.wsgi.ClosingIterator(iterable, callbacks=None)
These functions operate on the WSGI environment. They extract useful information or perform common manipulations:
- werkzeug.wsgi.get_host(environ, trusted_hosts=None)
- werkzeug.wsgi.responder(f)
Marks a function as responder. Decorate a function with it and it will automatically call the return value as WSGI application.
Example:
@responder def application(environ, start_response): return Response('Hello World!')
- werkzeug.testapp.test_app(environ, start_response)
Simple test application that dumps the environment. You can use it to check if Werkzeug is working properly:
>>> from werkzeug.serving import run_simple >>> from werkzeug.testapp import test_app >>> run_simple('localhost', 3000, test_app) * Running on http://localhost:3000/
The application displays important information from the WSGI environment, the Python interpreter and the installed libraries.