new way to integrate vacciation data into website: have separate head and foot file and regenerate index every day

This commit is contained in:
fordprefect
2020-12-29 18:46:30 +01:00
parent 6591ea628e
commit 92883d52bf
4 changed files with 44 additions and 37 deletions

View File

@@ -149,11 +149,17 @@ def plot(data, countries, pop, **kwargs):
print(f"=====> plotting failed for {loc}, skipping plot. Error: {e}")
## vaccination overview html
with open("vac_state.html", "w") as f:
# header
with open("index.html", "w") as f:
# site header
with open("index.html.head", "r") as g:
f.write(g.read())
# table header
f.write("<table><tr><th>Land</th><th>Impfungen</th><th>Impfrate</th></tr>\n")
# data
for loc, tvac, rvac in vaccs:
f.write(f"<tr><td>{loc}</td><td>" + f"{tvac:,d}".replace(",",".") + f"</td><td>{rvac:3.3f}%</td></tr>\n".replace(".", ","))
# footer
# table footer
f.write("</table>\n")
# site footer
with open("index.html.foot", "r") as g:
f.write(g.read())