diff --git a/api.py b/api.py index 7e8a268bb21d0b75035a96cc88ca8228871746a6..da19258264a45e4d3552d0259dc117750d9b99a2 100644 --- a/api.py +++ b/api.py @@ -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