0
@app.route('/sera/<mount_type>')
@app.route('/sera', methods=['POST'])
def return_pages():
    if request.method == 'POST':
        usin = request.form.get('serval')
        global mount_type
        mount_type = usin 
    #this section runs independend of the search box
    if mount_type == 'acongagua':
        return render_template('result.html',aa=acongagua.names, ac=acongagua.location, ad=acongagua.metre_height, ae=acongagua.feet_height)
    elif mount_type == 'adams':
        return render_template('result.html',aa=adams.names, ac=adams.location, ad=adams.metre_height, ae=adams.feet_height)
    else:
        return 'YOU HAVE ENTERED AN INCORRECT VALUE'

if __name__ == '__main__':
    app.run(debug=True, use_reloader=True)

that is the python flask code i'm trying to run the first if statement should run when the form is filled and should have its values passed to the seconf if statement

1 Answers1

0

You can use redirect to redirect the request, and pass the value as URL paramater:

from flask import redirect

@app.route('/sera/<mount_type>')
@app.route('/sera', methods=['POST'])
def return_pages():
    if request.method == 'POST':
        usin = request.form.get('serval')
        return redirect(url_for('return_pages', mount_type=usin))  # <--
    ...
Grey Li
  • 11,664
  • 4
  • 54
  • 64