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