How to enable CORS in Flask?

  • Install package flask-cors

pip install flask-cors

  • How use Flask:
  • from flask import Flask
    from flask_cors import CORS
    
    app = Flask(__name__)
    CORS(app)
    
    @app.route("/")
      def home():
      return "Hello, cross-origin-world!"
    
    if __name__=='__main__':
        app.run(debug=True)