flask web 8.6.1节,使用itsdangerous生成确认令牌
今天继续学习<<Flask Web开发>>,第8.6.1节,使用itsdangerous生成确认令牌,在90页,简短的shell会话显示了如何使用itsdangerous包生成用户id的安全令牌,我在PyCharm中
Microsoft Windows [版本 10.0.16299.431]
(c) 2017 Microsoft Corporation。保留所有权利。
(venv) D:\PycharmProjects>cd flasky
(venv) D:\PycharmProjects\flasky>python manage shell
python: can't open file 'manage': [Errno 2] No such file or directory
(venv) D:\PycharmProjects\flasky>python manage.py shell
* Serving Flask app "app" (lazy loading)
* Environment: production
WARNING: Do not use the development server in a production environment.
Use a production WSGI server instead.
* Debug mode: on
* Restarting with stat
* Debugger is active!
* Debugger PIN: 215-070-750
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
>>> from manage import app
>>> from itsdangerous import TimedJSONWebSignatureSerializer as Serializer
>>> s = Serializer(app.config['SECRET_KEY'],expires_in = 3600)
>>> token = s.dump({'confirm':23})
Traceback (most recent call last):
File "<console>", line 1, in <module>
TypeError: dump() missing 1 required positional argument: 'f'
>>> token = s.dumps({'confirm':23})
>>> token
b'eyJhbGciOiJIUzI1NiIsImlhdCI6MTUyNjM1MDAxNywiZXhwIjoxNTI2MzUzNjE3fQ.eyJjb25maXJtIjoyM30.ijR0hzL6kxfwAFBaKMp_5k2oBYwCVMO_hSmoFlo5ooo'
>>> data = s.loads(token)
>>> data
{'confirm': 23}
>>>
上一篇: struts2上传下载文件及出现的问题 struts2上传下载
下一篇: PL/SQl 死循环,死锁