“Python Flask Access-Control-Allow-Origin” Ответ

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
Thoughtful Toad

ошибка Cors в колбе

from flask import Flask
from flask_cors import CORS, cross_origin

app = Flask(__name__)
CORS(app)

@app.route("/")
def helloWorld():
    return "Hello world"
Quaint Quail

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()
devil-cyber

Ответы похожие на “Python Flask Access-Control-Allow-Origin”

Вопросы похожие на “Python Flask Access-Control-Allow-Origin”

Больше похожих ответов на “Python Flask Access-Control-Allow-Origin” по Python

Смотреть популярные ответы по языку

Смотреть другие языки программирования