button in flask



def contact():
    if request.method == 'POST':
        if request.form['submit_button'] == 'Do Something':
            pass # do something
        elif request.form['submit_button'] == 'Do Something Else':
            pass # do something else
        else:
            pass # unknown
    elif request.method == 'GET':
        return render_template('contact.html', form=form)

Here is what the above code is Doing:
1. If the request method is POST, the form will be validated and then either
the ‘Do Something’ or ‘Do Something Else’ code will be executed.
2. If the request method is GET, the form will be displayed.
3. If the request method is neither POST or GET, the form will not be
displayed and the ‘unknown’ code will be executed.