summaryrefslogtreecommitdiff
path: root/link.cgi
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2022-12-01 22:45:08 +0000
committerubq323 <ubq323@ubq323.website>2022-12-01 22:45:08 +0000
commitf77c9ccffaca7c10d0b56346f5baa8756fbcbab9 (patch)
treed39612a398dd920bfec15db5638c00e860fe3c30 /link.cgi
parent9cc9cedabbf7dc1b6fcdad0b6a6feb8763b5777a (diff)
add link redirection thing, and documentation
Diffstat (limited to 'link.cgi')
-rwxr-xr-xlink.cgi23
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)