Files
aitsc/config/__init__.py

35 lines
813 B
Python
Raw Normal View History

import os
from .base import Config
from .development import DevelopmentConfig
from .production import ProductionConfig
from .testing import TestingConfig
from .local import LocalConfig
# 配置映射字典
config_map = {
'development': DevelopmentConfig,
'production': ProductionConfig,
'testing': TestingConfig,
'local': LocalConfig,
'default': DevelopmentConfig
}
def get_config():
"""
根据环境变量获取对应的配置类
环境变量: FLASK_ENV
可选值: development, production, testing, local
"""
env = os.environ.get('FLASK_ENV', 'development')
return config_map.get(env, config_map['default'])
# 导出配置类
__all__ = [
'Config',
'DevelopmentConfig',
'ProductionConfig',
'TestingConfig',
'LocalConfig',
'get_config'
]