BadRequestKeyError
html file:
{% block content %}
{{ super() }}
<p><label>Найти человека</label><input type="text" name="username" value="" requied /><input type="submit" value="Найти"></p>
{% endblock %}
.py file:
@app.route("/profile", methods=["POST", "GET"])
def profile():
if 'userLogged' not in session:
return redirect(url_for('login'))
else:
if request.method == 'POST':
con = sqlite3.connect("users.sqlite")
cur = con.cursor()
search = cur.execute("""SELECT * FROM persons""")
for el in search:
if el[1] == request.form['username']:
print("SHALOM")
return redirect("person")
return render_template('profile.html', menu=menu)
Error - werkzeug.exceptions.BadRequestKeyError: 400 Bad Request: The browser (or proxy) sent a request that this server could not understand. KeyError: 'username'