Skip to content
Snippets Groups Projects
Commit 6a282145 authored by Antoine Pietri's avatar Antoine Pietri
Browse files

config: add allowed_hosts config option

parent 158eb87f
No related branches found
Tags v0.0.92
No related merge requests found
......@@ -7,6 +7,7 @@ from swh.core import config
from swh.storage import get_storage
DEFAULT_CONFIG = {
'allowed_hosts': ('list', []),
'storage': ('dict', {
'cls': 'remote',
'args': {
......@@ -30,7 +31,7 @@ DEFAULT_CONFIG = {
})
}
swhweb_config = None
swhweb_config = {}
def get_config(config_file='webapp/webapp'):
......@@ -39,9 +40,9 @@ def get_config(config_file='webapp/webapp'):
dict. If no configuration file is provided, return a default
configuration."""
global swhweb_config
if not swhweb_config:
swhweb_config = config.load_named_config(config_file, DEFAULT_CONFIG)
cfg = config.load_named_config(config_file, DEFAULT_CONFIG)
swhweb_config.update(cfg)
config.prepare_folders(swhweb_config, 'log_dir')
swhweb_config['storage'] = get_storage(**swhweb_config['storage'])
return swhweb_config
......
......@@ -35,7 +35,7 @@ SECRET_KEY = swh_web_config['secret_key']
DEBUG = swh_web_config['debug']
DEBUG_PROPAGATE_EXCEPTIONS = swh_web_config['debug']
ALLOWED_HOSTS = ['127.0.0.1', 'localhost']
ALLOWED_HOSTS = ['127.0.0.1', 'localhost'] + swh_web_config['allowed_hosts']
# Application definition
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment