Html Variable Value Is Not Changing In Flask
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'
Solution 1:
You really don't need flag
at all, it is confusing the entire logic:
@app.route('/',methods = ['POST','GET'])
def home():
if request.method == "POST":
jsdata = request.form['data']
session['jsdata']=jsdata
session['ans'] = get_data(session['jsdata'])
ans = session.get('ans', 999) # try to get it from the session,
# if fails, set it to 999 default value
return render_template('/index.html', ans=ans)
Post a Comment for "Html Variable Value Is Not Changing In Flask"