I have two def for creating question and previewing question.
I want to pass a question's ID from def create() to def preview(). But the def preview() cannot realize the ID.
I have try using return redirect(url_for('preview', question_id=question_id)) and in my def preview() I used question_id = request.args.get('question_id',type=str).
How can I fix that?
My code is here:
@app.route("/create/", methods=['GET','POST'])
def create():
question = "How are you?"
question_id = "123456"
return redirect(url_for('preview'), question_id=question_id)
@app.route("/preview/", methods=['GET','POST'])
def preview():
question_id = request.args.get('question_id', type=str)
print(question_id)
question_idparam to theurl_forfunction instead ofredirect. Please correct to :redirect(url_for('preview'), question_id=question_id)