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
)
| 247 | |
| 248 | |
| 249 | def 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 | |
| 273 | def abort(code: int | BaseResponse, *args: t.Any, **kwargs: t.Any) -> t.NoReturn: |