wsgi_app() — flask Function Reference
Architecture documentation for the wsgi_app() function in app.py from the flask codebase.
Entity Profile
Dependency Diagram
graph TD fb0e1e8e_33b2_bf68_f1ae_2eace5216191["wsgi_app()"] 9f8cc56e_d5c4_e7a8_438a_3124c0dd5de5["Flask"] fb0e1e8e_33b2_bf68_f1ae_2eace5216191 -->|defined in| 9f8cc56e_d5c4_e7a8_438a_3124c0dd5de5 77edbf40_079c_81a7_885c_08c72aee053e["__call__()"] 77edbf40_079c_81a7_885c_08c72aee053e -->|calls| fb0e1e8e_33b2_bf68_f1ae_2eace5216191 ba0faaf2_249e_8d3d_df7c_6a7b65513741["request_context()"] fb0e1e8e_33b2_bf68_f1ae_2eace5216191 -->|calls| ba0faaf2_249e_8d3d_df7c_6a7b65513741 4deafda5_fb07_c30c_ad12_a72767b1a116["full_dispatch_request()"] fb0e1e8e_33b2_bf68_f1ae_2eace5216191 -->|calls| 4deafda5_fb07_c30c_ad12_a72767b1a116 738c25cf_2aef_f422_7e87_9520ea64ce07["handle_exception()"] fb0e1e8e_33b2_bf68_f1ae_2eace5216191 -->|calls| 738c25cf_2aef_f422_7e87_9520ea64ce07 519276e3_fb95_dd4f_f8b0_6550aeb8f81b["push()"] fb0e1e8e_33b2_bf68_f1ae_2eace5216191 -->|calls| 519276e3_fb95_dd4f_f8b0_6550aeb8f81b 9c229141_7037_617a_d840_a301ff163737["pop()"] fb0e1e8e_33b2_bf68_f1ae_2eace5216191 -->|calls| 9c229141_7037_617a_d840_a301ff163737 style fb0e1e8e_33b2_bf68_f1ae_2eace5216191 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/flask/app.py lines 1547–1597
def wsgi_app(
self, environ: WSGIEnvironment, start_response: StartResponse
) -> cabc.Iterable[bytes]:
"""The actual WSGI application. This is not implemented in
:meth:`__call__` so that middlewares can be applied without
losing a reference to the app object. Instead of doing this::
app = MyMiddleware(app)
It's a better idea to do this instead::
app.wsgi_app = MyMiddleware(app.wsgi_app)
Then you still have the original application object around and
can continue to call methods on it.
.. versionchanged:: 0.7
Teardown events for the request and app contexts are called
even if an unhandled error occurs. Other events may not be
called depending on when an error occurs during dispatch.
:param environ: A WSGI environment.
:param start_response: A callable accepting a status code,
a list of headers, and an optional exception context to
start the response.
"""
ctx = self.request_context(environ)
error: BaseException | None = None
try:
try:
ctx.push()
response = self.full_dispatch_request(ctx)
except Exception as e:
error = e
response = self.handle_exception(ctx, e)
except:
error = sys.exc_info()[1]
raise
return response(environ, start_response)
finally:
if "werkzeug.debug.preserve_context" in environ:
environ["werkzeug.debug.preserve_context"](ctx)
if (
error is not None
and self.should_ignore_error is not None
and self.should_ignore_error(error)
):
error = None
ctx.pop(error)
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does wsgi_app() do?
wsgi_app() is a function in the flask codebase, defined in src/flask/app.py.
Where is wsgi_app() defined?
wsgi_app() is defined in src/flask/app.py at line 1547.
What does wsgi_app() call?
wsgi_app() calls 5 function(s): full_dispatch_request, handle_exception, pop, push, request_context.
What calls wsgi_app()?
wsgi_app() is called by 1 function(s): __call__.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free