code: def redirect(where: Optional[str] = None,
               default: Optional[str] = None,
               override: Optional[str] = None,
               _anchor: Optional[str] = None,
               _cls: Optional[Union[object, type]] = None,
               _external: Optional[bool] = False,
               _external_host: Optional[str] = None,
               _method: Optional[str] = None,
               _scheme: Optional[str] = None,
               **values,
               ) -> Response:
      flask_url_for_kwargs = dict(_anchor=_anchor, _external=_external,
                                  _external_host=_external_host, _method=_method,
                                  _scheme=_scheme, **values)
      urls = [url_for(request.args.get('next'), **flask_url_for_kwargs),
              url_for(request.form.get('next'), **flask_url_for_kwargs)]
      if where:
          urls.append(url_for(where, _cls=_cls, **flask_url_for_kwargs))
      if default:
          urls.append(url_for(default, _cls=_cls, **flask_url_for_kwargs))
      if override:
          urls.insert(0, url_for(override, _cls=_cls, **flask_url_for_kwargs))
      for url in urls:
          if _validate_redirect_url(url, _external_host):
              return flask_redirect(url)
      return flask_redirect('/')