diff options
author | Johannes Löthberg <johannes@kyriasis.com> | 2017-01-12 21:21:49 +0000 |
---|---|---|
committer | Johannes Löthberg <johannes@kyriasis.com> | 2017-01-12 21:21:49 +0000 |
commit | f3d6affcbd8414c2d69405559535a34e01b1b04b (patch) | |
tree | 6d630980bd8bcdc8d21e32f0ff17a89eac5d41b6 | |
parent | afe0b8eb2f3ff67a481f1ad1cb9420c07a47ae20 (diff) | |
download | ktt-f3d6affcbd8414c2d69405559535a34e01b1b04b.tar.xz |
Set the stop name in the generated html
Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
-rw-r--r-- | real.py | 16 | ||||
-rw-r--r-- | templates/layout.html | 1 |
2 files changed, 9 insertions, 8 deletions
@@ -21,16 +21,16 @@ def write_data(data, site_id): f.write(data) -def write_html(data, site_id): +def write_html(data, site_id, stop_name, path): template = env.get_template('layout.html') - with open('{}.html'.format(site_id), 'w+') as f: - f.write(template.render(data=data)) + with open('{}/{}.html'.format(path, site_id), 'w+') as f: + f.write(template.render(data=data, stop_name=stop_name)) -def write_txt(data, site_id): +def write_txt(data, site_id, stop_name, path): template = env.get_template('layout.txt') - with open('{}.txt'.format(site_id), 'w+') as f: - f.write(template.render(data=data)) + with open('{}/{}.txt'.format(path, site_id), 'w+') as f: + f.write(template.render(data=data, stop_name=stop_name)) if __name__ == '__main__': @@ -53,5 +53,5 @@ if __name__ == '__main__': else: data = get_data(config['key'], config['site_id']) - write_html(data, config['site_id']) - write_txt(data, config['site_id']) + write_html(data, config['site_id'], config['stop_name'], config['output_path']) + write_txt(data, config['site_id'], config['stop_name'], config['output_path']) diff --git a/templates/layout.html b/templates/layout.html index aead13f..937a12a 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -23,6 +23,7 @@ p { <div class="root"> + <h1>{{ stop_name }}</h1> <p>Last updated: {{ data['ResponseData']['LatestUpdate'] }}</p> <ul> |