Skip to content

Instantly share code, notes, and snippets.

@xspager
Last active January 8, 2022 17:32
Show Gist options
  • Save xspager/7cf2284f927edb6c4cbf to your computer and use it in GitHub Desktop.
Save xspager/7cf2284f927edb6c4cbf to your computer and use it in GitHub Desktop.
#!/usr/bin/env /home/xspager/.lua/52/bin/cgilua.fcgi
--cgilua.handle("index.lp")
--require('mobdebug').start("192.168.0.6")
cgilua.htmlheader()
local SERVER_VARIABLES = {"PATH_TRANSLATED", "QUERY_STRING", "REMOTE_ADDR", "REQUEST_METHOD", "SCRIPT_NAME", "SERVER_PROTOCOL", "SERVER_SOFTWARE"}
cgilua.put([[
<html>
<head></head>
<body>
]])
cgilua.put("<ul>")
for i = 1, #SERVER_VARIABLES do
cgilua.put("<li>"..SERVER_VARIABLES[i]..": "..cgilua.servervariable(SERVER_VARIABLES[i]).."</li>")
end
cgilua.put("</ul>")
cgilua.put([[
<form action="" method="POST" enctype="multipart/form-data">
<input name="my_text" type="text"></input>
<input name="my_file" type="file">
<input type="submit" />
</form>
]])
if cgilua.POST.my_text ~= nil then
cgilua.put("<code>"..cgilua.POST.my_text.."</code>")
end
if cgilua.POST.my_file ~= nil then
cgilua.put("<textarea>"..cgilua.POST.my_file.file:read("*a").."</textarea>")
end
cgilua.put([[
</body>
</html>
]])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment