webwriter.py 661 B

12345678910111213141516171819
  1. import os
  2. class WebWriter:
  3. def __init__(self):
  4. self.path = '~/public_html/img/'
  5. def _generate(self, data):
  6. if data is None:
  7. return
  8. if not os.path.exists(os.path.expanduser(self.path)):
  9. os.makedirs(os.path.expanduser(self.path))
  10. with open(os.path.expanduser('~/public_html/img/index.html'),'w+') as f:
  11. f.write("<html><body>\n")
  12. f.write("<font size=7>ANYTHING AND EVERYTHING ON THIS PAGE MAY BE NSFW. YOU HAVE BEEN WARNED.</font><br />\n")
  13. for line in data:
  14. f.write(line[2] + " pasted link <a href=\"" + line[1] + "\">" + line[1] + "</a> at "+str(line[3])+"<br>\n")
  15. f.write("</html></body>\n")