Reputation: 98
I'm trying to use Amazon Textract but upon my API call it says allow-access-origin-header not present
and makes the API not work. I have taken steps to see that the API itself does work but I can't use this to deploy to customers who want to use the OCR. Is there a python package or maybe a way to make it work?
It is basically a browser problem so how do I add this header to it.
Upvotes: 0
Views: 482
Reputation: 2227
First install this package
$ pip install -U flask-cors
then import it to your app.py and implement it like this
...
from flask_cors import CORS, cross_origin
...
app = Flask(__name__)
cors = CORS(app, resources={r"/api/*": {"origins": "*"}})
app.config['CORS_HEADERS'] = 'Content-Type'
@app.route("/api/something", methods=["POST"])
@cross_origin()
def something():
return Response('{"something":"something else"}', status=200, mimetype='application/json')
Hope it helps :-)
Upvotes: 1