【发布时间】:2021-08-25 15:09:52
【问题描述】:
我正在使用 Flask 制作订票应用。但是现在我对如何将数据从一个页面发送到另一个页面有点困惑,就像这个 sn-p 的代码:
@app.route('/index', methods = ['GET', 'POST'])
def index():
if request.method == 'GET':
date = request.form['date']
return redirect(url_for('main.booking', date=date))
return render_template('main/index.html')
@app.route('/booking')
def booking():
return render_template('main/booking.html')
date 变量是来自表单的请求,现在我想将 date 数据发送到 booking 函数。什么是用于此目的的术语..?
【问题讨论】:
-
您尝试过会话存储吗?重定向方法不允许将数据发送到另一个页面。
-
我现在正在阅读它@VillageMonkey,但仍在考虑,在这种情况下我应该使用会话还是cookie..?