这个问题在这里已有答案:
我有两个烧瓶应用程序在本地主机和不同的端口,5000和5001上运行。首先我在端口5000上运行烧瓶应用程序,然后如果我的烧瓶app 1的条件满足,我想将其重定向到index.html运行端口号5001。
我试过返回render_template('http://localhost:5001/index.html'),但它给出了一个错误jinja2.exceptions.TemplateNotFound:http://localhost:5001/index.html
这个错误是因为你无法渲染另一个应用程序的模板,因为在这种情况下重定向你可以像下面那样,这是我的烧瓶应用程序,它只是简单地展示如何在应用程序之间重定向
from flask import Flask,redirect
app = Flask(__name__)
@app.route("/")
def test():
return redirect('http://localhost:5001', code=301)