diff --git a/app/__init__.py b/app/__init__.py index 5a186aa..557edd1 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -12,6 +12,12 @@ from app.utils.logging import configure_logger, logger from .apis import register_apis +import app.config as _app_config + +app_config = { + k: getattr(_app_config, k) + for k in dir(_app_config) if not k.startswith("_") +} # 基本路径 APP_PATH = os.path.abspath(os.path.dirname(__file__)) @@ -77,13 +83,10 @@ def create_or_override_default_admin(app): def create_app(): app = Flask(__name__) - app.config.from_envvar( - config_path_env - ) # 获取配置文件,仅从环境变量读取,均需要配置环境变量 + app.config.from_mapping(app_config) configure_logger(app) # 配置日志记录(放在最前,会被下面调用) logger.info("-" * 50) - logger.info("使用配置文件: {}".format(os.environ.get(config_path_env))) # 连接数据库 from app.models import connect_db @@ -119,9 +122,7 @@ def init_db(app: Flask): def create_celery() -> Celery: # 为celery创建app app = Flask(__name__) - app.config.from_envvar( - config_path_env - ) # 获取配置文件,仅从环境变量读取,均需要配置环境变量 + app.config.from_mapping(app_config) # 通过app配置创建celery实例 created = Celery( app.name, diff --git a/config.py b/app/config.py similarity index 98% rename from config.py rename to app/config.py index bebf498..32c0627 100644 --- a/config.py +++ b/app/config.py @@ -130,3 +130,5 @@ "Content-Type", "X-Requested-With", ] +# manga-image-translator worker +MIT_STORAGE_ROOT = env.get("MIT_STORAGE_ROOT", None)