支持跨域请求
This commit is contained in:
parent
9b23d8a3a6
commit
d4ca0aa483
4
app.py
4
app.py
|
@ -4,6 +4,7 @@ from logging.config import dictConfig
|
||||||
|
|
||||||
from flask import Flask
|
from flask import Flask
|
||||||
from flask.logging import default_handler
|
from flask.logging import default_handler
|
||||||
|
from flask_cors import CORS
|
||||||
|
|
||||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src'))
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src'))
|
||||||
from database.mongodb import initialize_db
|
from database.mongodb import initialize_db
|
||||||
|
@ -22,6 +23,9 @@ app = Flask(__name__)
|
||||||
app.logger.removeHandler(default_handler)
|
app.logger.removeHandler(default_handler)
|
||||||
app.config.from_pyfile("settings/dev.py")
|
app.config.from_pyfile("settings/dev.py")
|
||||||
|
|
||||||
|
# 允许跨域
|
||||||
|
CORS(app)
|
||||||
|
|
||||||
# 初始化数据库连接
|
# 初始化数据库连接
|
||||||
initialize_db(app)
|
initialize_db(app)
|
||||||
initialize_redis(app)
|
initialize_redis(app)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# 主要依赖如下
|
# 主要依赖如下
|
||||||
Flask==2.0.2
|
Flask==2.0.2
|
||||||
|
Flask-Cors==3.0.10
|
||||||
flask-mongoengine==1.0.0
|
flask-mongoengine==1.0.0
|
||||||
flask-redis==0.4.0
|
flask-redis==0.4.0
|
||||||
Flask-RESTful==0.3.9
|
Flask-RESTful==0.3.9
|
||||||
|
|
Loading…
Reference in New Issue