From f77c9ccffaca7c10d0b56346f5baa8756fbcbab9 Mon Sep 17 00:00:00 2001 From: ubq323 Date: Thu, 1 Dec 2022 22:45:08 +0000 Subject: add link redirection thing, and documentation --- link.cgi | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 link.cgi (limited to 'link.cgi') 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("

bad request

") +else: + l=len(order) + m = george[order[(ind+offs)%l]] + print("Location: "+m) -- cgit v1.2.3