向cookie里添加信息
from Flask import Flask, make_response app = Flask(__name__) @app.route("/") def main(): text = "<h1>Flaks Nb</h1>" res = make_response(text) res.set_cookie("language", "Python") return res if __name__ == "__main__": app.run()
运行后可以看到:
添加响应头信息
from Flask import Flask, make_response app = Flask(__name__) @app.route("/") def main(): text = "<h1>Flaks Nb</h1>" res = make_response(text) res.headers["My_headers"] = "Python" return res if __name__ == "__main__": app.run()
运行后: