1

セッションデータ /json を設定できます」

me@air9:28:18 ⮀ ~ ⮀ curl -v -X POST http://127.0.0.1:5000 -d '{"email": "user@email.com", "password": "p"}' -H "Content-Type: application/json"
* About to connect() to 127.0.0.1 port 5000 (#0)
*   Trying 127.0.0.1...
* connected
* Connected to 127.0.0.1 (127.0.0.1) port 5000 (#0)
> POST / HTTP/1.1
> User-Agent: curl/7.27.0
> Host: 127.0.0.1:5000
> Accept: */*
> Content-Type: application/json
> Content-Length: 44
>
* upload completely sent off: 44 out of 44 bytes
* HTTP 1.0, assume close after body
< HTTP/1.0 200 OK
< Content-Type: application/json
< Content-Length: 9
< Set-Cookie: session="DRRrrffY/WGHU80TJ++KY5UaoYU=?USER_TOKEN=UycuZUp3RndjRVJ3Q0FJQk1CZWVJY1pRVVNzSlpNSEo5cF9DZGw5Q1RaSGFUZU9PNTBObVp3U3lxanMyTzU2U3VtaEM4aXBKbXZtdXFNcExDVERiYVBzOUtIMF9maUJGQ0UudHA0NEsyd3ZxRWREaHlGQmw5cUNiclpVZnNFJwpwMQou"; Path=/; HttpOnly
< Server: Werkzeug/0.8.3 Python/2.7.2
< Date: Sun, 14 Apr 2013 16:28:32 GMT
<
* Closing connection #0
"success"%

セッションデータを取得するコードは次のとおりです

    try:
        print session
        user = load_token(session['USER_TOKEN'])
    except ValueError:
        return redirect(url_for('/'))
    except:
        print repr(sys.exc_info())

以下をcurlで叩くと

curl -v -b "session='DRRrrffY/WGHU80TJ++KY5UaoYU=?USER_TOKEN=UycuZUp3RndjRVJ3Q0FJQk1CZWVJY1pRVVNzSlpNSEo5cF9DZGw5Q1RaSGFUZU9PNTBObVp3U3lxanMyTzU2U3VtaEM4aXBKbXZtdXFNcExDVERiYVBzOUtIMF9maUJGQ0UudHA0NEsyd3ZxRWREaHlGQmw5cUNiclpVZnNFJwpwMQou'" http://127.0.0.1:5000/users/uuid/transactions

サーバーログが出力されます

<SecureCookieSession {}>
(<type 'exceptions.KeyError'>, KeyError('USER_TOKEN',), <traceback object at 0x109994248>)

私が間違っていることは何ですか?

セッションデータを取り戻すにはどうすればよいですか?

4

1 に答える 1