summaryrefslogtreecommitdiff
path: root/link.cgi
blob: e6ec9458a6d83655fbdf43920f2130843b9511c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env python3

from georgedata import george
order = list(george.keys())

from os import getenv
from urllib.parse import parse_qs
qs = getenv("QUERY_STRING")
query = parse_qs(qs)
try:
    member = query["from"][0]
    dir = query["dir"][0]
    ind = order.index(member)
    offs = {"next":1,"prev":-1}[dir]
except (ValueError,KeyError):
    print("Status: 400")
    print("Content-Type: text/html")
    print()
    print("<h1 style=\"color:red\">bad request</h1>")
else:
    l=len(order)
    m = george[order[(ind+offs)%l]]
    print("Location: "+m)
    print()