“Python Flask Access-Control-Wallow-Origin” Kode Jawaban

Python Flask Access-Control-Wallow-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

Kesalahan CORS dalam Flask

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

Lemah CORS Kebijakan Tidak ada akses-kontrol-awal-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

Jawaban yang mirip dengan “Python Flask Access-Control-Wallow-Origin”

Pertanyaan yang mirip dengan “Python Flask Access-Control-Wallow-Origin”

Lebih banyak jawaban terkait untuk “Python Flask Access-Control-Wallow-Origin” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya