ROUTE_PREFIX for easier proxying

This commit is contained in:
boyska 2017-12-08 21:24:37 +01:00
parent 3a034a0754
commit 1e4a5fc791
4 changed files with 12 additions and 5 deletions

View file

@ -19,6 +19,7 @@ def get_conf(prefix='LARIGIRA_'):
conf['CACHING_TIME'] = 10
conf['DB_URI'] = os.path.join(conf_dir, 'db.json')
conf['SCRIPTS_PATH'] = os.path.join(conf_dir, 'scripts')
conf['ROUTE_PREFIX'] = ''
conf['BOOTSTRAP_SERVE_LOCAL'] = True
conf['SECRET_KEY'] = 'Please replace me!'
conf['MPD_WAIT_START'] = True

View file

@ -17,7 +17,9 @@ from larigira.timegen import get_timegenerator, timegenerate
from larigira import forms
from larigira.config import get_conf
from .suggestions import get_suggestions
db = Blueprint('db', __name__, url_prefix='/db', template_folder='templates')
db = Blueprint('db', __name__,
url_prefix=get_conf()['ROUTE_PREFIX'] + '/db',
template_folder='templates')
def get_model():
@ -172,7 +174,9 @@ def edit_event(alarmid):
actions = tuple(model.get_actions_by_alarm(alarm))
return render_template('edit_event.html',
alarm=alarm, all_actions=allactions,
actions=actions)
actions=actions,
routeprefix=get_conf()['ROUTE_PREFIX']
)
@db.route('/api/alarm/<alarmid>/actions', methods=['POST'])

View file

@ -31,7 +31,7 @@ $(function() {
return $(li).data('id');
});
jQuery.post(
'/db/api/alarm/' + my_id + '/actions',
'{{routeprefix}}/db/api/alarm/' + my_id + '/actions',
{"actions[]": ids.toArray()}
);
});

View file

@ -11,8 +11,10 @@ from werkzeug.contrib.cache import SimpleCache
from .dbadmin import db
from .config import get_conf
rpc = Blueprint('rpc', __name__, url_prefix='/api')
viewui = Blueprint('view', __name__, url_prefix='/view',
rpc = Blueprint('rpc', __name__,
url_prefix=get_conf()['ROUTE_PREFIX'] + '/api')
viewui = Blueprint('view', __name__,
url_prefix=get_conf()['ROUTE_PREFIX'] + '/view',
template_folder='templates')