diff options
Diffstat (limited to 'searx/__init__.py')
| -rw-r--r-- | searx/__init__.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/searx/__init__.py b/searx/__init__.py index a57588cd3..2f3ebfcfe 100644 --- a/searx/__init__.py +++ b/searx/__init__.py @@ -19,9 +19,10 @@ import certifi import logging from os import environ from os.path import realpath, dirname, join, abspath, isfile +from io import open from ssl import OPENSSL_VERSION_INFO, OPENSSL_VERSION try: - from yaml import load + from yaml import safe_load except: from sys import exit, stderr stderr.write('[E] install pyyaml\n') @@ -37,6 +38,7 @@ def check_settings_yml(file_name): else: return None + # find location of settings.yml if 'SEARX_SETTINGS_PATH' in environ: # if possible set path to settings using the @@ -50,8 +52,8 @@ if not settings_path: raise Exception('settings.yml not found') # load settings -with open(settings_path) as settings_yaml: - settings = load(settings_yaml) +with open(settings_path, 'r', encoding='utf-8') as settings_yaml: + settings = safe_load(settings_yaml) ''' enable debug if @@ -87,3 +89,8 @@ if OPENSSL_VERSION_INFO[0:3] < (1, 0, 2): logger.warning('You are using an old openssl version({0}), please upgrade above 1.0.2!'.format(OPENSSL_VERSION)) logger.info('Initialisation done') + +if 'SEARX_SECRET' in environ: + settings['server']['secret_key'] = environ['SEARX_SECRET'] +if 'SEARX_BIND_ADDRESS' in environ: + settings['server']['bind_address'] = environ['SEARX_BIND_ADDRESS'] |