summaryrefslogtreecommitdiff
path: root/examples/cgi/cgi-bin
diff options
context:
space:
mode:
authortjpcc <tjp@ctrl-c.club>2023-01-10 13:46:35 -0700
committertjpcc <tjp@ctrl-c.club>2023-01-10 13:46:35 -0700
commit96f3a7607ffbdb349a4c2eff35efdf11b8d35a4e (patch)
tree8f1755bd3f3aedf33784f66aab9feccdd36c165e /examples/cgi/cgi-bin
parentdb7b6ef07254d61dee46a863786458e15a6459f6 (diff)
Add a CGI contrib
Diffstat (limited to 'examples/cgi/cgi-bin')
-rwxr-xr-xexamples/cgi/cgi-bin/cowsay16
1 files changed, 16 insertions, 0 deletions
diff --git a/examples/cgi/cgi-bin/cowsay b/examples/cgi/cgi-bin/cowsay
new file mode 100755
index 0000000..e63e909
--- /dev/null
+++ b/examples/cgi/cgi-bin/cowsay
@@ -0,0 +1,16 @@
+#!/usr/bin/env sh
+
+set -euo pipefail
+
+if [ -z "$QUERY_STRING" ];
+then
+ printf "10 Enter a phrase.\r\n"
+ exit 0
+fi
+
+decodeURL() { printf "%b\n" "$(sed 's/+/ /g; s/%\([0-9a-fA-F][0-9a-fA-F]\)/\\x\1/g;')"; }
+
+printf "20 text/gemini\r\n\`\`\`\n"
+echo $QUERY_STRING | decodeURL | cowsay
+echo "\`\`\`"
+echo "\n=> $SCRIPT_NAME again"