支持跨域请求

This commit is contained in:
chenzuoqing 2021-12-15 20:24:21 +08:00
parent 9b23d8a3a6
commit d4ca0aa483
2 changed files with 5 additions and 0 deletions

4
app.py
View File

@ -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)

View File

@ -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