“Cors Flask” Kode Jawaban

Cors Flask

from flask import Flask
from flask_cors import CORS

app = Flask(__name__)
CORS(app, resources={r"*": {"origins": "*"}})
Leo

instal flask_cors

$ pip install flask-cors
Fierce Fox

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

Cors Flask

@app.route("/", methods=["GET"])
def get_example():
    """GET in server"""
    response = jsonify(message="Simple server is running")

    # Enable Access-Control-Allow-Origin
    response.headers.add("Access-Control-Allow-Origin", "*")
    return response
Powerful Partridge

Jawaban yang mirip dengan “Cors Flask”

Pertanyaan yang mirip dengan “Cors Flask”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya