MCPcopy
hub / github.com/pallets/flask / request_context

Method request_context

src/flask/app.py:1407–1421  ·  view source on GitHub ↗

Create a :class:`~flask.ctx.RequestContext` representing a WSGI environment. Use a ``with`` block to push the context, which will make :data:`request` point at this request. See :doc:`/reqcontext`. Typically you should not call this from your own code. A request

(self, environ: WSGIEnvironment)

Source from the content-addressed store, hash-verified

1405 return AppContext(self)
1406
1407 def request_context(self, environ: WSGIEnvironment) -> RequestContext:
1408 """Create a :class:`~flask.ctx.RequestContext` representing a
1409 WSGI environment. Use a ``with`` block to push the context,
1410 which will make :data:`request` point at this request.
1411
1412 See :doc:`/reqcontext`.
1413
1414 Typically you should not call this from your own code. A request
1415 context is automatically pushed by the :meth:`wsgi_app` when
1416 handling a request. Use :meth:`test_request_context` to create
1417 an environment and context instead of this method.
1418
1419 :param environ: a WSGI environment
1420 """
1421 return RequestContext(self, environ)
1422
1423 def test_request_context(self, *args: t.Any, **kwargs: t.Any) -> RequestContext:
1424 """Create a :class:`~flask.ctx.RequestContext` for a WSGI

Callers 4

test_request_contextMethod · 0.95
wsgi_appMethod · 0.95

Calls 1

RequestContextClass · 0.85