我的login
端点看起来像
@app.route('/login/', methods=['GET', 'POST'])
def login():
if request.method == 'POST':
print request.form # debug line, see data printed below
user = User.get(request.form['uuid'])
if user and hash_password(request.form['password']) == user._password:
login_user(user, remember=True) # change remember as preference
return redirect('/home/')
else:
return 'GET on login not supported'
当我使用 测试这个curl
时,GET
调用看起来像
⮀ ~PYTHONPATH ⮀ ⭠ 43± ⮀ curl http://127.0.0.1:5000/login/
GET on login not supported
但是POST
,我无法访问表单数据并获取HTTP 400
⮀ ~PYTHONPATH ⮀ ⭠ 43± ⮀ curl -d "{'uuid': 'admin', 'password': 'admin'}" http://127.0.0.1:5000/login/
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>400 Bad Request</title>
<h1>Bad Request</h1>
<p>The browser (or proxy) sent a request that this server could not understand.</p>
但是在服务器上,我的调试信息会打印以下内容
ImmutableMultiDict([("{'uuid': 'admin', 'password': 'admin'}", u'')])
我在哪里print request.form
。我无法理解我做错了什么