Waitress WSGI Server
Waitress is a production-quality pure-Python WSGI server with a focus on simplicity and reliability. It's actively maintained by the Pylons Project, receiving frequent updates to support new Python versions and address security concerns. The current version is 3.0.2.
Warnings
- breaking Waitress dropped support for Python 3.8 starting with version 3.0.1. Running on Python 3.8 or older will result in errors.
- breaking Waitress v3.0.2 changed how `trusted_proxy_headers` are handled for security. Untrusted values from proxy headers are now dropped, and Waitress *updates* the headers passed to the WSGI app with validated values. Applications might receive different, more secure header values than before, potentially breaking logic that relied on previously available, untrusted headers.
- breaking Starting with version 3.0.0, Waitress performs stricter validation of HTTP request methods and versions according to RFCs. Malformed requests that previously might have passed through could now be rejected with a 400 Bad Request.
- gotcha Waitress binds to `127.0.0.1` (localhost) by default. If you need to serve the application on a network interface accessible from other machines (e.g., in a Docker container or a public server), you must explicitly set the `host` parameter.
Install
-
pip install waitress
Imports
- serve
from waitress import serve
Quickstart
from waitress import serve
def simple_app(environ, start_response):
"""A barebones WSGI application."""
status = '200 OK'
headers = [('Content-type', 'text/plain; charset=utf-8')]
start_response(status, headers)
return [b"Hello from Waitress!"]
if __name__ == '__main__':
print("Serving on http://127.0.0.1:8080")
serve(simple_app, host='127.0.0.1', port=8080)