From e79fe819f672d3454532181182732080e056592a Mon Sep 17 00:00:00 2001 From: ubq323 Date: Sat, 11 Dec 2021 20:28:36 +0000 Subject: add existing content --- index.cgi | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100755 index.cgi (limited to 'index.cgi') diff --git a/index.cgi b/index.cgi new file mode 100755 index 0000000..280b59d --- /dev/null +++ b/index.cgi @@ -0,0 +1,39 @@ +#!/usr/bin/env python3 + +from georgedata import the +import urllib.request +import pathlib, datetime +p=pathlib.Path("/srv/web/george.gh0.pw/status.txt") +a=datetime.datetime.now().timestamp()-p.stat().st_mtime +if a > 300: + try: + st = urllib.request.urlopen("https://coral.shoes/george-status/george-status-html-but-epic").read().decode("utf-8") + except: + st = "a webring" + with open(p,"w") as f: + f.write(st) +else: + with open(p) as f: + st = f.read().strip() + +sts = st.split("\x1e") + + + +with open("oldindex.html") as f: + index = f.read() + +lt = '
  • {name}
  • ' +lt2 = '{name}' +def r(h): + import random + random.shuffle(h) + return h +s ="\n".join(r(list(lt.format(link=v[0],colour=v[1],name=k) for k,v in the.items()))) +s2="\n".join(r(list( lt2.format(colour=v[1],name=k) for k,v in the.items() if len(v)>2 and v[2] ))) +c='['+(', '.join(r(list(f'"{c}"' for c in (v[1] for v in the.values())))))+']' + + +print("Content-Type: text/html"); print() +print(index.replace("LINKS",s).replace("COLOURS",c).replace("COUNCIL",s2).replace("STATUS",sts[0]).replace("FOOTNOTE",sts[1]).replace("COUNT",str(len(the)))) + -- cgit v1.2.3