Solve Cross Origin Resource Sharing with Flask

后端 未结 9 724
面向向阳花
面向向阳花 2020-11-28 03:59

For the following ajax post request for Flask (how can I use data posted from ajax in flask?):

$.ajax({
    url: \"http://127.0.0.1         


        
9条回答
  •  清酒与你
    2020-11-28 04:13

    Well, I faced the same issue. For new users who may land at this page. Just follow their official documentation.

    Install flask-cors

    pip install -U flask-cors
    

    then after app initialization, initialize flask-cors with default arguments:

    from flask import Flask
    from flask_cors import CORS
    
    app = Flask(__name__)
    CORS(app)
    
    @app.route("/")
    def helloWorld():
       return "Hello, cross-origin-world!"
    

提交回复
热议问题