最简单的解决方案是最终 URL 中的“abcd”可以是实际结果:
@app.route("/result")
def calculate_result():
s, t = request.args.get("s"), request.args.get("t")
# Calculate result with s and t
return redirect(url_for(".display_results", result=result))
@app.route("/final/<result>")
def display_results(result):
return render_template("results.html", result=result)
如果不能,那么您可以session
改用:
@app.route("/result")
def calculate_result():
s, t = request.args.get("s"), request.args.get("t")
# Calculate result with s and t
session["result"] = result
return redirect(url_for(".display_results", result=result))
@app.route("/final/abcd")
def display_results():
result = session.get("result")
return render_template("results.html", result=result)