aboutsummaryrefslogtreecommitdiff
path: root/www/cgi-bin/test.lua
diff options
context:
space:
mode:
authoriceyrazor <iceyrazor@mailfence.com>2026-08-01 01:25:42 -0500
committericeyrazor <iceyrazor@mailfence.com>2026-08-01 01:25:42 -0500
commit69c416c85bf92fca4b59aa78888a8aefbd0e0640 (patch)
treea6122738014d565e7dac6d7c75ec7f0971d0a014 /www/cgi-bin/test.lua
init
Diffstat (limited to 'www/cgi-bin/test.lua')
-rwxr-xr-xwww/cgi-bin/test.lua43
1 files changed, 43 insertions, 0 deletions
diff --git a/www/cgi-bin/test.lua b/www/cgi-bin/test.lua
new file mode 100755
index 0000000..c86b3f5
--- /dev/null
+++ b/www/cgi-bin/test.lua
@@ -0,0 +1,43 @@
+#!/usr/bin/env luajit
+
+local cgi = require("cgi")
+local req_params = require("req-params")
+local str=""
+
+if req_params.param("password") and req_params.param("password") == "401" then
+ cgi.render("401 Unauthorized",{["Content-Type"]="text/html"},401)
+ return
+end
+
+-- Access GET parameters
+if next(req_params.get_params) then
+ str=str..m("h2","GET parameters:")
+ for k,v in pairs(req_params.get_params) do
+ str=str..k.." = "..v.."<br>"
+ end
+end
+
+-- Access POST parameters
+if next(req_params.post_params) then
+ str=str..m("h2","POST parameters:")
+ for k,v in pairs(req_params.post_params) do
+ str=str..k.." = "..v.."<br>"
+ end
+end
+
+-- Combined helper
+local name = req_params.param("name") or "anonymous"
+str=str..m("p","Hello, "..name.."!")
+
+cgi.render(m("html",
+ m("head",
+ m("title","ssg test")
+ )..
+ m("body",
+ m("h1","Hello from Lua CGI")..
+ m("p", "ssg test")..
+ m("p",_VERSION)..
+ str
+ )
+),
+{["Content-Type"]="text/html"},200) \ No newline at end of file