-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.py
25 lines (20 loc) · 815 Bytes
/
index.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import os
import html
def is_html_file(filename):
return filename.endswith(".html")
def createHTML(depts):
with open("./output/index.html", "w") as f:
f.write("<html><body><ul>\n")
f.write(f"<H1>List of cities</H1>\n")
for dept in depts:
f.write(f"<H2>{dept}</H2>\n")
directories = os.listdir(f"./output/{dept}")
print(directories)
for filename in directories:
if is_html_file(filename):
pathname = os.path.join(str(dept),filename)
f.write('<li><a href="%s">%s</a></li>\n' %
(html.escape(pathname, True), html.escape(os.path.splitext(filename)[0])))
f.write("</ul></body></html>\n")
if __name__ == '__main__':
createHTML([75,92,93,94])