16
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Flask で Cors を使う

Last updated at Posted at 2017-11-06

Flask で CORS (Cross Origin Resource Sharing) を使う方法です。

Flask-CORSをインストールします。

sudo pip install -U flask-cors

Flask を起動する時、python welcome.py としていたら、welcome.py の冒頭に追加コードを書きます。

import sys
import os

from flask import Flask
from flask_cors import CORS
from flask import jsonify
from flask import request
app = Flask(__name__)
CORS(app)

追加したのは、上記のうちの次の2行です。

from flask_cors import CORS
CORS(app)

Flask を起動します。

python welcome.py
16
13
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
16
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?