Javascript - No 'Access-Control-Allow-Origin' header is present on the requested resource

后端 未结 7 1778
天命终不由人
天命终不由人 2020-11-27 17:25

I need to send data through XmlHttpRequest from JavaScript to Python server. Because I\'m using localhost, I need to use CORS. I\'m using the Flask framework an

7条回答
  •  春和景丽
    2020-11-27 18:06

    I have used the flask-cors extension.

    Install using pip install flask-cors

    Then it's simply

    from flask_cors import CORS
    app = Flask(__name__)
    CORS(app)
    

    This will allow all domains

提交回复
热议问题