【发布时间】:2020-01-05 18:42:36
【问题描述】:
我有一个函数('postcode'),它接受用户的输入并生成两个我想传递给另一个函数('constituency')的变量。
如何在函数之间传递两个参数,以便只将一个参数传递给 url?
app("/postcode", methods=["GET", "POST"])
def postcode():
form = PostcodeForm()
if form.validate_on_submit():
pc = form.postcode.data.replace(" ", "").strip()
if validate(pc) == True:
code, const = dosomething(pc)
return redirect(url_for('app.constituency', const_id=const)), code
return render_template("template1.html", form=form)
@app.route("/constituency/<string:const_id>")
def constituency(const_id):
const = const_id
people = People.query.filter_by(code=code) # I want the value of "code" here to come from the function 'postcode' above
return render_template("template2.html", people=people, const=const)
【问题讨论】: