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 redirect the client to
codeint = 303The HTTP status code for the redirect, defaulting to 303 (See Other)
Response`type[BaseResponse]None` = None

Returns

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