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
31
32
33
34
35
36
37
38
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\x1e"
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))))
|