There is form with two <input type="submit">
. But when i'm sending it, second submit causes error.
layout:
<form action="{{ url_for('index') }}" method="post">
<input type="submit" name="add" value="Like">
<input type="submit" name="remove" value="Dislike">
</form>
main.py:
...
if request.method == 'POST':
if request.form['add']:
return redirect(url_for('index'))
elif request.form['remove']:
return redirect(url_for('index'))
...
First submit(add) works well, but second(remove)...:
Bad Request The browser(or proxy) sent a request that this server could not understand.
How can i fix this error?
UPD:
It was pretty simple:
request.form returns ImmutableMultiDict:
...
if 'Like' in request.form.values():
...
elif 'Dislike' in request.form.values():
...
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…