I am working on a flask project.
I have created a from with following description
from flask_wtf import FlaskForm
from wtforms import StringField, SubmitField
from wtforms.validators import DataRequired
class SearchRestaurantForm(FlaskForm):
query = StringField('Query', validators=[DataRequired()])
searchButton = SubmitField('Search')
This form is accessed in a route function named search
as shown below.
@app.route("/search", methods=['GET', 'POST'])
def search():
form = SearchRestaurantForm()
if form.validate_on_submit():
query_ = form.query.data
return redirect('/result?query='+query_)
return render_template('search.html', title='Search', form = form)
I want to use the data of the StringField query
in another route function named result
as shown below.
@app.route("/result", methods=['GET'])
def result():
query__ = query_
restaurants = find_appro_res(query__)
return render_template('result.html', res_list=restaurants)
I don't know how can I access the str
of search
function in result
function.
I am new in flask.