I have written this code in Flask
ans = 999
@app.route('/', methods=['POST', 'GET'])
def home():
flag = 0
global ans
session["ans"] = 0
if (request.method == "POST"):
jsdata = request.form['data']
flag = 1
session['jsdata'] = jsdata
if (flag == 1):
ans = get_data(session['jsdata'])
return render_template('/index.html',ans=ans)
return render_template('/index.html',ans=ans)
When the value of flag was 0, in index.html
it shows 999, but when value of flag changes to 1 and if condition
is executed index.html
still show value 999 not the values it got from function. and when I print the and
in if condition
for debugging it shows correct value.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…