From a6011d83e6140b8e12e7701f1e479c2fd65ce211 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Tue, 30 Apr 2019 16:41:38 +0200 Subject: gui: make template folder configurable --- python/gui.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'python/gui.py') diff --git a/python/gui.py b/python/gui.py index a9328ee..7823175 100755 --- a/python/gui.py +++ b/python/gui.py @@ -30,15 +30,14 @@ from jinja2 import Environment, FileSystemLoader from gui.api import API from lib import zmqrc -env = Environment(loader=FileSystemLoader('gui/templates')) - base_js = ["js/odr.js"] base_css = ["css/odr.css"] class Root: - def __init__(self, dpd_port): + def __init__(self, dpd_port, end): self.mod_rc = zmqrc.ModRemoteControl("localhost") self.api = API(self.mod_rc, dpd_port) + self.env = env @cherrypy.expose def index(self): @@ -46,30 +45,30 @@ class Root: @cherrypy.expose def about(self): - tmpl = env.get_template("about.html") + tmpl = self.env.get_template("about.html") return tmpl.render(tab='about', js=base_js, is_login=False) @cherrypy.expose def home(self): - tmpl = env.get_template("home.html") + tmpl = self.env.get_template("home.html") js = base_js + ["js/odr-home.js"] return tmpl.render(tab='home', js=js, css=base_css, is_login=False) @cherrypy.expose def rcvalues(self): - tmpl = env.get_template("rcvalues.html") + tmpl = self.env.get_template("rcvalues.html") js = base_js + ["js/odr-rcvalues.js"] return tmpl.render(tab='rcvalues', js=js, is_login=False) @cherrypy.expose def modulator(self): - tmpl = env.get_template("modulator.html") + tmpl = self.env.get_template("modulator.html") js = base_js + ["js/odr-modulator.js"] return tmpl.render(tab='modulator', js=js, is_login=False) @cherrypy.expose def predistortion(self): - tmpl = env.get_template("predistortion.html") + tmpl = self.env.get_template("predistortion.html") js = base_js + ["js/odr-predistortion.js"] return tmpl.render(tab='predistortion', js=js, is_login=False) @@ -106,9 +105,11 @@ if __name__ == '__main__': }) staticdir = os.path.realpath(config['static_directory']) + templatedir = os.path.realpath(config['templates_directory']) + env = Environment(loader=FileSystemLoader(templatedir)) cherrypy.tree.mount( - Root(dpd_port), config={ + Root(dpd_port, env), config={ '/': { }, '/dpd': { 'tools.staticdir.on': True, -- cgit v1.2.3