diff --git a/config.py b/config.py index 03016db..0305753 100644 --- a/config.py +++ b/config.py @@ -1,4 +1,5 @@ # Import community modules. +import os import json # Get App configuration. @@ -15,6 +16,8 @@ def redis_conf(): conf = file.read() conf = json.loads(conf) file.close() + if 'STATIC_ENDPOINT' in os.environ: + conf['cdn']['static']['endpoint'] = os.environ['STATIC_ENDPOINT'] return conf app_conf = app_conf() diff --git a/init.py b/init.py index a1a763f..0ff7584 100644 --- a/init.py +++ b/init.py @@ -1,5 +1,4 @@ -# Import community modules. -import os +# Import community modules. import sys import json from elasticapm.contrib.flask import ElasticAPM @@ -43,8 +42,6 @@ def home(): vars = {} vars['environment'] = app_conf['environment'] vars['cdn'] = app_conf['cdn'] - if os.environ['STATIC_ENDPOINT']: - vars['cdn']['static']['endpoint'] = os.environ['STATIC_ENDPOINT'] vars['accounts'] = redis.engine.hgetall(redis_conf['key_prefix']['account']) for key,value in vars['accounts'].items(): vars['accounts'][key] = json.loads(value) @@ -55,8 +52,6 @@ def account_create(): vars = {} vars['environment'] = app_conf['environment'] vars['cdn'] = app_conf['cdn'] - if os.environ['STATIC_ENDPOINT']: - vars['cdn']['static']['endpoint'] = os.environ['STATIC_ENDPOINT'] if request.method=='GET': return render_template('account/create.html',vars=vars) elif request.method=='POST': @@ -79,8 +74,6 @@ def account_update(id): vars = {} vars['environment'] = app_conf['environment'] vars['cdn'] = app_conf['cdn'] - if os.environ['STATIC_ENDPOINT']: - vars['cdn']['static']['endpoint'] = os.environ['STATIC_ENDPOINT'] if request.method=='GET': vars['account'] = json.loads(redis.engine.hget(redis_conf['key_prefix']['account'],id)) vars['account']['id'] = id @@ -100,8 +93,6 @@ def account_view(id): vars = {} vars['environment'] = app_conf['environment'] vars['cdn'] = app_conf['cdn'] - if os.environ['STATIC_ENDPOINT']: - vars['cdn']['static']['endpoint'] = os.environ['STATIC_ENDPOINT'] vars['account'] = json.loads(redis.engine.hget(redis_conf['key_prefix']['account'],id)) vars['account']['id'] = id return render_template('account/view.html',vars=vars) @@ -111,8 +102,6 @@ def contact_view(act_id): vars = {} vars['environment'] = app_conf['environment'] vars['cdn'] = app_conf['cdn'] - if os.environ['STATIC_ENDPOINT']: - vars['cdn']['static']['endpoint'] = os.environ['STATIC_ENDPOINT'] vars['account'] = json.loads(redis.engine.hget(redis_conf['key_prefix']['account'],act_id)) vars['account']['id'] = act_id vars['contacts'] = redis.engine.hgetall(redis_conf['key_prefix']['contact']+':'+str(act_id)) @@ -125,8 +114,6 @@ def contact_create(act_id): vars = {} vars['environment'] = app_conf['environment'] vars['cdn'] = app_conf['cdn'] - if os.environ['STATIC_ENDPOINT']: - vars['cdn']['static']['endpoint'] = os.environ['STATIC_ENDPOINT'] if request.method=='GET': vars['account'] = json.loads(redis.engine.hget(redis_conf['key_prefix']['account'],act_id)) vars['account']['id'] = act_id @@ -150,8 +137,6 @@ def contact_update(act_id,id): vars = {} vars['environment'] = app_conf['environment'] vars['cdn'] = app_conf['cdn'] - if os.environ['STATIC_ENDPOINT']: - vars['cdn']['static']['endpoint'] = os.environ['STATIC_ENDPOINT'] if request.method=='GET': vars['account'] = json.loads(redis.engine.hget(redis_conf['key_prefix']['account'],act_id)) vars['account']['id'] = act_id @@ -172,8 +157,6 @@ def lead_view(act_id): vars = {} vars['environment'] = app_conf['environment'] vars['cdn'] = app_conf['cdn'] - if os.environ['STATIC_ENDPOINT']: - vars['cdn']['static']['endpoint'] = os.environ['STATIC_ENDPOINT'] vars['account'] = json.loads(redis.engine.hget(redis_conf['key_prefix']['account'],act_id)) vars['account']['id'] = act_id vars['leads'] = redis.engine.hgetall(redis_conf['key_prefix']['lead']+':'+str(act_id)) @@ -186,8 +169,6 @@ def lead_create(act_id): vars = {} vars['environment'] = app_conf['environment'] vars['cdn'] = app_conf['cdn'] - if os.environ['STATIC_ENDPOINT']: - vars['cdn']['static']['endpoint'] = os.environ['STATIC_ENDPOINT'] if request.method=='GET': vars['account'] = json.loads(redis.engine.hget(redis_conf['key_prefix']['account'],act_id)) vars['account']['id'] = act_id @@ -211,8 +192,6 @@ def lead_update(act_id,id): vars = {} vars['environment'] = app_conf['environment'] vars['cdn'] = app_conf['cdn'] - if os.environ['STATIC_ENDPOINT']: - vars['cdn']['static']['endpoint'] = os.environ['STATIC_ENDPOINT'] if request.method=='GET': vars['account'] = json.loads(redis.engine.hget(redis_conf['key_prefix']['account'],act_id)) vars['account']['id'] = act_id diff --git a/requirements.txt b/requirements.txt index c321c5c..bd9447c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,6 @@ -flask==0.12.4 +MarkupSafe==2.1.3 +Jinja2==3.1.2 +flask==2.2.5 redis==2.10.6 elastic-apm[flask]==3.0.5 pytest==4.6.5 \ No newline at end of file