1 @app.route(‘/‘) 2 def index(): 3 """ 4 读取一个cookies 5 :return: 6 """ 7 # 读取cookies 8 username = request.cookies.get(‘username‘) 9 # 存取cookies 10 return ‘i love ai‘ 11 12 13 @app.route(‘/set‘) 14 def set_(): 15 """ 16 生成一个cookies 17 :return: 18 """ 19 # 生成一个会话请求, 方便cookies数据的绑定 20 resp = make_response(‘...‘) 21 resp.set_cookies(‘username‘, ‘This Name‘) 22 return resp