@app.route('/login', methods=['POST', 'GET'])
def login():
errors = []
if request.method == 'POST':
email = request.form['email']
password = request.form['password']
#Check the user's e-mail
try:
u = User(email)
except UserError, e:
errors.append(e)
else:
#Check the user's password
if not u.authenticatePassword(password):
errors.append(('password','Invalid password'))
return render_template('login.html',error=errors)
#Set the session
s = Session()
s.user_id = u.user_id
s.ip = request.remote_addr
#Try to set the cookie
if s.setSession():
response = make_response( render_template('login.html',error=errors))
response.set_cookie('session_id', s.session_id)
return response
return render_template('login.html',error=errors)
if s.setSession():
response = make_response(redirect('/home'))
response.set_cookie('session_id', s.session_id)
return response
my
redirect_to_index = redirect('/login')
response = app.make_response(redirect_to_index )
response.set_cookie('Cookies','fjdsafjafj9392jfn',max_age= 60 * 60)
return response
# return redirect("htpp://www.baidu.com")
resp = make_response(redirect('http://www.baidu.com')) #resp = app.make_response(render_template('index.html',form=myForm)) #设置cookies有效期一个小时 resp.set_cookie('Cookies','fjdsafjafj9392jfn',max_age= 60 * 60,path='/')
相关推荐
CTFsession伪造脚本,有解密和加密的,一定要有私钥才能进行。
Building-Web-Applications-with-Flask-Use-Python-and-Flask-to-build-amazing-web-applications-just-the-way-you-want-them-.pdf
python-flask-and-django-full-stack-python-for-web-development
需要的环境:keras 2.0.1 及 2.0.5 版本均经过测试可用。推荐Python 2.7,支持Python 3.6. 此外需要numpy, matplotlib, os, h5py, argparse. 推荐使用anaconda安装
资源来自pypi官网。 资源全名:flask-session-cookie-manager-1.2.1.tar.gz
Flask 基础模板-------
该资源为Flask-2.2.2-py3-none-any.whl,欢迎下载使用哦!
资源分类:Python库 所属语言:Python 资源全名:flask_cookie_decode-0.3.0-py2.py3-none-any.whl 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
使用python脚本更改或生成cookie
资源来自pypi官网。 资源全名:flask-restful-swagger-3-0.2.0.tar.gz
python web开发,基于flask的练手项目---文件上传下载的管理系统的设计与实现 python web开发,基于flask的练手项目---文件上传下载的管理系统的设计与实现 python web开发,基于flask的练手项目---文件上传下载的...
# pacman -S flask-session-cookie-manager{3,2} 吉特 ArchLinux 两者python3 etn python2: $ git clone https://github.com/noraj/flask-session-cookie-manager.git && cd flask-session-cookie-manager # ...
Flask-Web-Development-Developing-Web-Applications-with-Python.pdf
资源来自pypi官网。 资源全名:flask_restless_client-0.4.3-py2.py3-none-any.whl
flask、session、cookie解加密脚本
资源来自pypi官网。 资源全名:Flask_AppBuilder-3.2.0rc1-py3-none-any.whl
python库,解压后可用。 资源全名:flask_unsign_wordlist-0.0.5-py2.py3-none-any.whl
flask-palletsprojects-com-en-1.1.x.pdf Flask web 开发框架官方文档