diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2019-04-30 16:41:38 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2019-04-30 16:41:38 +0200 |
commit | a6011d83e6140b8e12e7701f1e479c2fd65ce211 (patch) | |
tree | ca6765d4fb89200c2cab07f825f380d0f91af607 /python | |
parent | 4556bf9eeb5083935ead5df3a436d18a3016cfcd (diff) | |
download | dabmod-a6011d83e6140b8e12e7701f1e479c2fd65ce211.tar.gz dabmod-a6011d83e6140b8e12e7701f1e479c2fd65ce211.tar.bz2 dabmod-a6011d83e6140b8e12e7701f1e479c2fd65ce211.zip |
gui: make template folder configurable
Diffstat (limited to 'python')
-rw-r--r-- | python/gui-dpdce.ini | 1 | ||||
-rwxr-xr-x | python/gui.py | 19 |
2 files changed, 11 insertions, 9 deletions
diff --git a/python/gui-dpdce.ini b/python/gui-dpdce.ini index 4385c80..496adf5 100644 --- a/python/gui-dpdce.ini +++ b/python/gui-dpdce.ini @@ -31,3 +31,4 @@ port=8099 logs_directory=gui/logs static_directory=gui/static +templates_directory=gui/templates 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, |