I have written this code in Flask
ans = 999
@app.route('/', methods=['POST', 'GET'])
def home():flag = 0global anssession["ans"] = 0if (request.method == "POST"):jsdata = request.form['data']flag = 1session['jsdata'] = jsdataif (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.