Home

WSGIcompatible

WSGI-compatible refers to software that conforms to the Web Server Gateway Interface (WSGI), a standardized interface between Python web servers and Python web applications or frameworks. Established to promote portability and interoperability, WSGI defines how a server hands a request to an application and how the application returns a response. A WSGI-compliant application is a callable, typically defined as def application(environ, start_response): ...; it receives two arguments: environ, a dict-like object containing request data and environment variables, and start_response, a callable used to begin the HTTP response. The application must return an iterable yielding byte strings. It should call start_response with a status string (e.g., '200 OK') and a list of (header_name, header_value) tuples before yielding the body. The write() callable may be provided for back-compatibility but is optional and rarely used.

WSGI servers, such as Gunicorn, uWSGI, or mod_wsgi, import or load a WSGI application and route HTTP

Note that WSGI is synchronous by design (distinct from ASGI) and expects the body to be bytes

requests
by
invoking
it
per
request.
Middleware
can
wrap
applications
to
modify
environment
or
response.
Popular
Python
frameworks
like
Django,
Flask,
and
Pyramid
are
WSGI-compatible,
as
are
many
microframeworks
and
WSGI
adapters.
in
Python
3.
Correct
handling
of
headers,
streaming,
and
error
handling
are
important
for
compatibility
across
servers
and
middleware.