Solve Cross Origin Resource Sharing with Flask

后端 未结 9 722
面向向阳花
面向向阳花 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:05

    You can get the results with a simple:

    @app.route('your route', methods=['GET'])
    def yourMethod(params):
        response = flask.jsonify({'some': 'data'})
        response.headers.add('Access-Control-Allow-Origin', '*')
        return response
    

提交回复
热议问题