“Python Flask Access-Control-Allow-Origin” Code-Antworten

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 -Fehler in der Flasche

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-Richtlinie 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

Ähnliche Antworten wie “Python Flask Access-Control-Allow-Origin”

Fragen ähnlich wie “Python Flask Access-Control-Allow-Origin”

Weitere verwandte Antworten zu “Python Flask Access-Control-Allow-Origin” auf Python

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen