Questions tagged «bad-request»

1
在Flask应用程序中提交表单时,错误请求错误的原因是什么?
在阅读了许多类似的听起来问题和相关的Flask文档之后,我似乎无法弄清楚提交表单时是什么导致了以下错误: 400错误的要求 浏览器(或代理)发送了该服务器无法理解的请求。 尽管表单始终可以正确显示,但是当我提交与以下两个功能之一关联的HTML表单时,就会发生错误的请求: @app.route('/app/business', methods=['GET', 'POST']) def apply_business(): if request.method == 'POST': new_account = Business(name=request.form['name_field'], email=request.form['email_field'], account_type="business", q1=request.form['q1_field'], q2=request.form['q2_field'], q3=request.form['q3_field'], q4=request.form['q4_field'], q5=request.form['q5_field'], q6=request.form['q6_field'], q7=request.form['q7_field'], account_status="pending", time=datetime.datetime.utcnow()) db.session.add(new_account) db.session.commit() session['name'] = request.form['name_field'] return redirect(url_for('success')) return render_template('application.html', accounttype="business") @app.route('/app/student', methods=['GET', 'POST']) def apply_student(): if request.method == 'POST': new_account = Student(name=request.form['name_field'], email=request.form['email_field'], …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.