I want to do a return with the ans variable only when i get the "question" variable from the HTML page , Otherwise, do it without the variable. But even though that the code enter to the if statment (when i'm print the 'question' or the 'ans'), the second return is still being made (the one sent without the extra variable) Is there another way to render each time with a different variable? What am I doing wrong?
app = Flask(__name__)
@app.route("/")
def home():
if 'question' in request.args:
question= request.args.get('question')
print(question)
print(respond(question))
return render_template("HTML.html" , ans=respond(question))
else:
return render_template("HTML.html", ans =respond(""))
if __name__ == '__main__':
port = int(os.environ.get('PORT', 5000))
if port == 5000:
app.debug = True
app.run(host='0.0.0.0', port=port)