1from flask import Flask
2from flask_cors import CORS, cross_origin
3
4app = Flask(__name__)
5CORS(app)
6
7@app.route("/")
8def helloWorld():
9 return "Hello world"
1# initialization
2app = Flask(__name__)
3app.config['SECRET_KEY'] = 'the quick brown fox jumps over the lazy dog'
4app.config['CORS_HEADERS'] = 'Content-Type'
5
6cors = CORS(app, resources={r"/foo": {"origins": "http://localhost:port"}})
7
8@app.route('/foo', methods=['POST'])
9@cross_origin(origin='localhost',headers=['Content- Type','Authorization'])
10def foo():
11 return request.json['inputVar']
12
13if __name__ == '__main__':
14 app.run()
15
1@app.route('your route', methods=['GET'])
2def yourMethod(params):
3 response = flask.jsonify({'some': 'data'})
4 response.headers.add('Access-Control-Allow-Origin', '*')
5 return response
6