Sometimes, we want to fix Bad Request Error when submitting form in a Python Flask app.
In this article, we’ll look at how to fix Bad Request Error when submitting form in a Python Flask app.
How to fix Bad Request Error when submitting form in a Python Flask app?
To fix Bad Request Error when submitting form in a Python Flask app, we use the request.form
dict to get the form values with keys that match one of the name
attribute of an input element.
For instance, we write
<input name="question_field" placeholder="question one">
to add an input with name
set to question_field
.
Then we write
request.form['question_field']
in our view function to get the value of the input with name
attribute set to question_field
.
Conclusion
To fix Bad Request Error when submitting form in a Python Flask app, we use the request.form
dict to get the form values with keys that match one of the name
attribute of an input element.