每次网页访问者点击'/'(主页)时,我都会调用一个函数.我也会在其他函数中使用该函数的结果.有关如何做到这一点的任何建议?
@app.route('/')
def home():
store = index_generator() #This is the local variable I would like to use
return render_template('home.html')
@app.route('/home_city',methods = ['POST'])
def home_city():
CITY=request.form['city']
request_yelp(DEFAULT_LOCATION=CITY,data_store=store) """I would like to use the results here"""
return render_template('bank.html')
Run Code Online (Sandbox Code Playgroud)