32 lines
689 B
Python
32 lines
689 B
Python
import sys
|
|
import os.path
|
|
from logging.config import dictConfig
|
|
|
|
from flask import Flask
|
|
from flask.logging import default_handler
|
|
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src'))
|
|
from database.mongodb import initialize_db
|
|
from routes import blueprint_api
|
|
from settings.dev import LOGGING
|
|
|
|
|
|
# 日志配置
|
|
dictConfig(LOGGING)
|
|
|
|
# app 实例,移除默认日志,加载配置文件
|
|
app = Flask(__name__)
|
|
app.logger.removeHandler(default_handler)
|
|
app.config.from_pyfile("settings/dev.py")
|
|
|
|
# 初始化数据库连接
|
|
initialize_db(app)
|
|
|
|
# 注册蓝图
|
|
app.register_blueprint(blueprint_api)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
app.run(host='0.0.0.0', port=5001, debug=True)
|
|
|