from flask import Blueprint,request,make_response
#request 来获取cookie
make_response 来设置和销毁cookie
cookie = Blueprint(“cookie”,name,url_prefix=’/cookie’)
#得到cookie 通过request
@cookie.route("/get/")
def get_cookie():
# 只是得到 键为name的cookie值
# return request.cookies.get(“name”,“xxxx”)
# 得到cookie所有值,以键值对表现出来
return request.cookies
#设置cookie 通过make_response
@cookie.route(’/set/’)
def set_cookie():
resp = make_response(“此内容不限”)
# 设置键为name的cookie值
resp.set_cookie(“name”, “woshishei”)
# 设置键为age的cookie值
resp.set_cookie(‘age’, ‘10’)
return resp
#销毁cookie 通过make_response
@cookie.route("/del/")
def del_cookie():
resp = make_response(“销毁cookie”)
# 删除键为name的cookie
resp.delete_cookie(“name”)
return resp