I have an HTML form that gets posted to a Flask route. However, request.form
is empty. If I try to access one of the values by id, I get a 400 error. How do
You need to Specify the form Action method in the Html page, and then mention the HTML Text box name inside the Tag.
And inside the .py module access the element using the name specified in the HTML tag.
@app.route('/PythonFunctionName', methods=['POST', 'GET'])
def getPage():
if request.method == 'POST':
strTextBoxVal= request.form['HTMLControlName'])
Print(strTextBoxVal)
return render_template('page.html')