summaryrefslogtreecommitdiff
path: root/yarrow.cgi
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2023-09-16 16:28:51 -0500
committersanine <sanine.not@pm.me>2023-09-16 16:28:51 -0500
commit4f124ec785486c8505c6303e0d0aa3e7090612c7 (patch)
tree252dee442d52c889c01cbc7afb4f7a0064698b7c /yarrow.cgi
parentb3f797fdea2f2227f95104a727a13a7a01ba98fa (diff)
add yarrow.cgi
Diffstat (limited to 'yarrow.cgi')
-rwxr-xr-xyarrow.cgi29
1 files changed, 29 insertions, 0 deletions
diff --git a/yarrow.cgi b/yarrow.cgi
new file mode 100755
index 0000000..7543f42
--- /dev/null
+++ b/yarrow.cgi
@@ -0,0 +1,29 @@
+#!/usr/bin/env lua5.1
+
+local marigold = require 'marigold-cgi.marigold'
+local h = marigold.h
+local b64 = require '3rdparty.base64'
+local json = require '3rdparty.json'
+local draw = require 'draw'
+
+
+local function error(message)
+ print('Content-type: text/plain\n')
+ print(string.format('ERROR: %s', message))
+ os.exit(1)
+end
+
+
+-- get statistics
+local metavars = marigold.get_metavars()
+local query = marigold.decode_query(metavars.query_string or '')
+if not query.statistics then
+ error('no statistics submitted!')
+end
+local statistics = json.decode(b64.decode(query.statistics))
+
+
+-- create & respond with image
+local svg = draw.draw(statistics)
+print('Content-type: image/svg+xml\n')
+print(svg)