安装模块
pip install flask-cors
全局允许跨域
from flask import Flask
from flask_cors import CORS
if __name__ == '__main__':
app = Flask(__name__)
@app.route('/', methods=['GET', 'POST'])
def index():
return 'HELLO WORD'
CORS(app, supports_credentials=True)
app.run(port=8123)
指定方法允许跨域
@app.route('/', methods=['GET', 'POST'])
@cross_origin()
def index():
return 'HELLO WORD'