Skip to content
Snippets Groups Projects
Commit 90e19a89 authored by David Trattnig's avatar David Trattnig
Browse files

Small, custom template engine.

parent 4705da76
No related branches found
No related tags found
No related merge requests found
......@@ -89,7 +89,7 @@ class EngineApi:
api = None
logger = None
trackservice_schema = None
# trackservice_schema = None
def __init__(self, config, api):
......@@ -145,6 +145,31 @@ class EngineApi:
# self.logger.info(spec.to_yaml())
def generate_html(self):
"""
Generates HTML based on the configuration options and templates.
"""
template = open("web/templates/clock.html", "r")
html = open("web/clock.html", "w")
config_options = {
"CONFIG-STATION-NAME": config.station_name,
"CONFIG-STATION-LOGO-URL": config.station_logo_url,
"CONFIG-STATION-LOGO-SIZE": config.station_logo_size,
"CONFIG-API-URL": config.exposed_api_url
}
content = template.read()
for key, value in config_options.items():
content = content.replace(":::"+key+":::", value)
html.write(content)
template.close()
html.close()
def run(self):
"""
Starts the API server.
......@@ -387,6 +412,7 @@ class ReportResource(Resource):
if __name__ == "__main__":
engine_api = EngineApi(config, api)
engine_api.generate_html()
engine_api.run()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment