<h3>Command Manager</h3>
<p>Manage which commands are available in your server.</p>
<form action={{url_for('dashboard')}} method="POST">
<input type="text" name="projectFilePath"><br>
<button type="submit" name="commandButton" class="btn btn-success btn-block"
value="Submit1">Save</button>
我的dashboard.html文件中的代码是
@app.route('/dashboard', methods=['GET', 'POST'])
@is_logged_in
def dashboard():
if request.method == 'POST':
form = request.form.to_dict()
print("Form", form)
print("The user has posted something!")
if request.form['prefixButton'] == 'Submit':
print("User has requested a prefix change!")
return render_template('dashboard.html')
elif request.form['commandButton'] == 'Submit1':
print("Command button")
return render_template('dashboard.html')
单击第一个按钮时,代码将按预期执行。我收到消息&#34;用户请求更改前缀&#34;。但是,当我点击第二个按钮时,我不断收到错误的请求错误。
错误请求
浏览器(或代理)发送了此服务器无法理解的请求。
我似乎无法理解为什么会得到这个 - 并且没有太多迹象表明实际出现了什么问题。
我也很肯定它不是KeyError,因为我得到以下输出:
('Form', {'commandButton': u'Submit1', 'projectFilePath': u'hi'})
编辑:
<button type="submit" name="commandButton" class="btn btn-success btn-block"
value="Submit1">Save</button>
<button type="submit" name="commandButton" class="btn btn-success btn-block"
value="Submit2">Save</button>