Skip to main content

redirect

Create a redirect response object.

def redirect(
location: str,
code: int = 303,
Response: type[BaseResponse] | None = None
) - > BaseResponse

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.

Parameters

NameTypeDescription
locationstrThe target URL or path to which the client should be redirected
codeint = 303The HTTP status code used for the redirect, typically 303, 302, or 301
Response`type[BaseResponse]None` = None

Returns

TypeDescription
BaseResponseA response object that triggers a browser redirection to the specified location