Answers for "flask access-control-allow-origin header"

6

cors error in flask

from flask import Flask
from flask_cors import CORS, cross_origin

app = Flask(__name__)
CORS(app)

@app.route("/")
def helloWorld():
    return "Hello world"
Posted by: Guest on June-17-2020
1

flask cors policy no 'access-control-allow-origin'

# initialization
app = Flask(__name__)
app.config['SECRET_KEY'] = 'the quick brown fox jumps over the lazy   dog'
app.config['CORS_HEADERS'] = 'Content-Type'

cors = CORS(app, resources={r"/foo": {"origins": "http://localhost:port"}})

@app.route('/foo', methods=['POST'])
@cross_origin(origin='localhost',headers=['Content- Type','Authorization'])
def foo():
    return request.json['inputVar']

if __name__ == '__main__':
   app.run()
Posted by: Guest on June-06-2021
0

python flask access-control-allow-origin

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

Code answers related to "flask access-control-allow-origin header"

Python Answers by Framework

Browse Popular Code Answers by Language