座右铭:怎么简单怎么来,以实现功能为主。
欢迎大家关注公众号与我交流
环境安装
pip install -U flask-cors
示例代码
from flask import Flask
from flask_cors import CORS, cross_origin
app = Flask(__name__)
CORS(app, supports_credentials=True)
@app.route("/", methods=["GET"])
@cross_origin() # 放在路由下面
def index():
return "Hello, World!"
if __name__ == "__main__":
app.run(debug=True, host='0.0.0.0', port=80)