From d4ca0aa483ff9b08a4f990def4e6b2545106c663 Mon Sep 17 00:00:00 2001 From: chenzuoqing Date: Wed, 15 Dec 2021 20:24:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E8=B7=A8=E5=9F=9F=E8=AF=B7?= =?UTF-8?q?=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.py | 4 ++++ docs/requirements.txt | 1 + 2 files changed, 5 insertions(+) diff --git a/app.py b/app.py index 1f4eee4..5bd2daa 100644 --- a/app.py +++ b/app.py @@ -4,6 +4,7 @@ from logging.config import dictConfig from flask import Flask from flask.logging import default_handler +from flask_cors import CORS sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src')) from database.mongodb import initialize_db @@ -22,6 +23,9 @@ app = Flask(__name__) app.logger.removeHandler(default_handler) app.config.from_pyfile("settings/dev.py") +# 允许跨域 +CORS(app) + # 初始化数据库连接 initialize_db(app) initialize_redis(app) diff --git a/docs/requirements.txt b/docs/requirements.txt index 5497352..278fe76 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,5 +1,6 @@ # 主要依赖如下 Flask==2.0.2 +Flask-Cors==3.0.10 flask-mongoengine==1.0.0 flask-redis==0.4.0 Flask-RESTful==0.3.9