1<input type="submit" name="submit_button" value="Do Something">
2<input type="submit" name="submit_button" value="Do Something Else">
3def contact():
4 if request.method == 'POST':
5 if request.form['submit_button'] == 'Do Something':
6 pass # do something
7 elif request.form['submit_button'] == 'Do Something Else':
8 pass # do something else
9 else:
10 pass # unknown
11 elif request.method == 'GET':
12 return render_template('contact.html', form=form)
1
2<form method ="post" action="/">
3 <button type="submit" name="submit_a" value="submit_a"> Submit_a </button>
4 <button type="submit" name="submit_b" value="submit_b"> Submit_b </button>
5</form>
6
7
8
9def submit():
10 if request.method == "POST":
11 if request.form.get("submit_a"):
12 # do something
13 elif request.form.get("submit_b"):
14 # do something else
15 elif request.method == "GET":
16 # do something
17
18