小编Mit*_*tch的帖子

如何在其他函数烧瓶中使用局部变量?

每次网页访问者点击'/'(主页)时,我都会调用一个函数.我也会在其他函数中使用该函数的结果.有关如何做到这一点的任何建议?

@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)

python variables flask

8
推荐指数
1
解决办法
2554
查看次数

标签 统计

flask ×1

python ×1

variables ×1