You should try running the Flask app in debug mode:
app.run(host='127.0.0.1', port=5000, debug=True)
That will give you a more detailed error message:
werkzeug.exceptions.BadRequestKeyError: 400 Bad Request: The browser (or proxy) sent a request that this server could not understand.
KeyError: 'number'
This indicates that there is no form item with the name number
in the submitted form. Looking at your HTML form, it looks like the name
attribute has been misplaced; you also need it in the select
element. This HTML form fixes the error:
<form action="#" method="POST">
<select name="number">
{% for i in range(length) %}
<option name="number">change number {{d[i]}}</option>
{% endfor %}
</select>
<input type="submit">
</form>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…