-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhtml_handler.py
More file actions
30 lines (23 loc) · 778 Bytes
/
html_handler.py
File metadata and controls
30 lines (23 loc) · 778 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import os.path
def append_div(author_url, username, body_text, filename):
global base_file
if os.path.exists(filename) == False:
return None
p_tag = "<p>"
p_tag += str(body_text)
p_tag += "</p>"
h_tag = "<p class=\"username\">"
h_tag += str(username)
h_tag += "</p><br>"
img_tag = "<img src={} class=\"avatar\"></img>".format(author_url)
container_div = "<div>"
container_div += img_tag
container_div += h_tag
container_div += p_tag
container_div += "</div>"
with open(str(filename), "a") as output_file:
output_file.write(container_div)
print("message added")
def generate_html(filename):
with open(str(filename), "a") as output_file:
output_file.write("</body></html>")