标签:red color flask 问题 需要 ret methods post 跨域问题
from flask import Flask import json from flask_cors import CORS Server = Flask(__name__) cors = CORS(Server, supports_credentials=True) Server.debug=True @Server.route(‘/‘) def hello_world(): return ‘Hello World!‘ @Server.route(‘/login‘,methods=[‘POST‘]) def login(): return ‘{"code":1,"msg":"success","data":""}‘ if __name__ == ‘__main__‘: Server.run(host=‘127.0.0.1‘,port=9003)
需要导入两个包 pip install flask、pip install flask_cors
flask_cors可以解决浏览器的跨域问题
标签:red color flask 问题 需要 ret methods post 跨域问题
原文地址:https://www.cnblogs.com/zebra-bin/p/13294441.html