私の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
。どこが間違っているのか理解できない