diff options
Diffstat (limited to 'link.cgi')
-rwxr-xr-x | link.cgi | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/link.cgi b/link.cgi new file mode 100755 index 0000000..c0b40a5 --- /dev/null +++ b/link.cgi @@ -0,0 +1,23 @@ +#!/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) |