标签:过期 code run loading 设置 mic turn 时间 通过
pip install flask_script
from flask import Flask from flask_script import Manager # 启动命令的管理类 app = Flask(__name__) # 创建manager管理类的对象 manager = Manager(app) @app.route("/index") def index(): return "index page" if __name__ == ‘__main__‘: # app.run(debug=True) # 通过管理对象来启动flask manager.run()
设计cookie与过期时间
from flask import Flask,make_response app = Flask(__name__) @app.route(‘/set_cookie‘) def set_cookie(): resp = make_response("success") # 设置cookie resp.set_cookie("itcast","python") resp.set_cookie("itcast1","python1",max_age=3600) return resp if __name__ == ‘__main__‘: app.run(debug=True,port=8000)
获取与删除cookie
@app.route("/get_cookie") def get_cookie(): c = request.cookies.get("itcast") return c @app.route("/delete_cookie") def delete_cookie(): resp = make_response("delete cookie success") # 删除cookie resp.delete_cookie("itcast1") return resp
标签:过期 code run loading 设置 mic turn 时间 通过
原文地址:https://www.cnblogs.com/topass123/p/13534643.html