Upload file in flask with other form elements fails with 400 error Upload file in flask with other form elements fails with 400 error flask flask

Upload file in flask with other form elements fails with 400 error


It gives an error because you try to access a form field that it cannot find, and assumes that somehow the request was bad, because it didn't include a required form field. You are trying to access:

host = request.form['host-prod-iterator']

However you have simply not given it a name in your HTML. If you give it a name, it should work:

<p>Iterator Host :     <input type="text" class="form-control" name="host-prod-iterator" id="host-prod-iterator" value="10.47.7.57" required></p>