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

Function redirect

src/flask/helpers.py:249–270  ·  view source on GitHub ↗

Create a redirect response object. If :data:`~flask.current_app` is available, it will use its :meth:`~flask.Flask.redirect` method, otherwise it will use :func:`werkzeug.utils.redirect`. :param location: The URL to redirect to. :param code: The status code for the redirect.

(
    location: str, code: int = 302, Response: type[BaseResponse] | None = None
)

Source from the content-addressed store, hash-verified

247
248
249def redirect(
250 location: str, code: int = 302, Response: type[BaseResponse] | None = None
251) -> BaseResponse:
252 """Create a redirect response object.
253
254 If :data:`~flask.current_app` is available, it will use its
255 :meth:`~flask.Flask.redirect` method, otherwise it will use
256 :func:`werkzeug.utils.redirect`.
257
258 :param location: The URL to redirect to.
259 :param code: The status code for the redirect.
260 :param Response: The response class to use. Not used when
261 ``current_app`` is active, which uses ``app.response_class``.
262
263 .. versionadded:: 2.2
264 Calls ``current_app.redirect`` if available instead of always
265 using Werkzeug's default ``redirect``.
266 """
267 if current_app:
268 return current_app.redirect(location, code=code)
269
270 return _wz_redirect(location, code=code, Response=Response)
271
272
273def abort(code: int | BaseResponse, *args: t.Any, **kwargs: t.Any) -> t.NoReturn:

Callers 7

createFunction · 0.90
updateFunction · 0.90
deleteFunction · 0.90
wrapped_viewFunction · 0.90
registerFunction · 0.90
loginFunction · 0.90
logoutFunction · 0.90

Calls 1

redirectMethod · 0.80

Tested by

no test coverage detected