summaryrefslogtreecommitdiff
path: root/index.cgi
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2021-12-11 20:28:36 +0000
committerubq323 <ubq323@ubq323.website>2021-12-11 20:28:36 +0000
commite79fe819f672d3454532181182732080e056592a (patch)
treed242d5e454026e40ebeeaa0c655e7764075ebd8e /index.cgi
add existing content
Diffstat (limited to 'index.cgi')
-rwxr-xr-xindex.cgi39
1 files changed, 39 insertions, 0 deletions
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 = '<li><a href="{link}" style="color:{colour}">{name}</a></li>'
+lt2 = '<span style="color:{colour}">{name}</span>'
+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))))
+