Flask通过make_response实现重定向 app.route("/index") def index(): headers = { 'content-type':'text/plain', 'location':'http://www.baidu.com' } # 使浏览器识别返回内容为字符串而不是html response = make_response("<html></html>",301) # 浏览器接收到301,302状态码之后,会在headers中寻找location以重定向 response.headers = headers return response