|
@ -10,6 +10,7 @@ from server.errors import BaseError, handle_base_error, \ |
|
|
handle_404_error |
|
|
handle_404_error |
|
|
from server.utility import json_utility, session_utility |
|
|
from server.utility import json_utility, session_utility |
|
|
|
|
|
|
|
|
|
|
|
LOGLEVEL = os.environ.get('SERVER_LOGLEVEL', 'INFO').upper() |
|
|
dictConfig({ |
|
|
dictConfig({ |
|
|
'version': 1, |
|
|
'version': 1, |
|
|
'formatters': {'default': { |
|
|
'formatters': {'default': { |
|
@ -21,7 +22,7 @@ dictConfig({ |
|
|
'formatter': 'default' |
|
|
'formatter': 'default' |
|
|
}}, |
|
|
}}, |
|
|
'root': { |
|
|
'root': { |
|
|
'level': 'INFO', |
|
|
|
|
|
|
|
|
'level': LOGLEVEL, |
|
|
'handlers': ['wsgi'] |
|
|
'handlers': ['wsgi'] |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
@ -48,11 +49,18 @@ def create_app(test_config: dict = None) -> Flask: |
|
|
TRAP_HTTP_EXCEPTIONS=True, |
|
|
TRAP_HTTP_EXCEPTIONS=True, |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
config_directory = os.getenv('SERVER_CONFIG_DIRECTORY', 'config') |
|
|
if test_config is None: |
|
|
if test_config is None: |
|
|
app.logger.debug('Loading configurations') |
|
|
app.logger.debug('Loading configurations') |
|
|
app.config.from_object('server.default_settings') |
|
|
|
|
|
app.config.from_pyfile('config.py', silent=True) |
|
|
|
|
|
|
|
|
default_settings = 'server.default_settings' |
|
|
|
|
|
app.logger.debug('Loading configuration from ' + default_settings) |
|
|
|
|
|
app.config.from_object(default_settings) |
|
|
|
|
|
config_file = config_directory + '/config.py' |
|
|
|
|
|
if os.path.exists(config_file): |
|
|
|
|
|
app.logger.debug('Loading config from ' + config_file) |
|
|
|
|
|
app.config.from_pyfile(config_file, silent=True) |
|
|
if os.getenv('SERVER_SETTINGS', None): |
|
|
if os.getenv('SERVER_SETTINGS', None): |
|
|
|
|
|
app.logger.debug('Loading config from SERVER_SETTINGS=' + os.getenv('SERVER_SETTINGS', '')) |
|
|
app.config.from_envvar('SERVER_SETTINGS') |
|
|
app.config.from_envvar('SERVER_SETTINGS') |
|
|
else: |
|
|
else: |
|
|
app.logger.debug('Loading test configuration') |
|
|
app.logger.debug('Loading test configuration') |
|
|