From 4fd287655a72b9aea14cdac715ad5b90ed082ed2 Mon Sep 17 00:00:00 2001 From: Raghuram Subramani Date: Sun, 19 Jun 2022 19:47:51 +0530 Subject: add circuitpython code --- circuitpython/lib/axtls/www/lua/test_main.lua | 46 +++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 circuitpython/lib/axtls/www/lua/test_main.lua (limited to 'circuitpython/lib/axtls/www/lua/test_main.lua') diff --git a/circuitpython/lib/axtls/www/lua/test_main.lua b/circuitpython/lib/axtls/www/lua/test_main.lua new file mode 100644 index 0000000..0e997a2 --- /dev/null +++ b/circuitpython/lib/axtls/www/lua/test_main.lua @@ -0,0 +1,46 @@ +cgilua.htmlheader() +cgilua.put[[ + +Script Lua Test + + +cgi = { +]] + +for i,v in pairs (cgi) do + if type(v) == "table" then + local vv = "{" + for a,b in pairs(v) do + vv = string.format ("%s%s = %s
\n", vv, a, tostring(b)) + end + v = vv.."}" + end + cgilua.put (string.format ("%s = %s
\n", i, tostring(v))) +end +cgilua.put "}
\n" +cgilua.put ("Remote address: "..cgilua.servervariable"REMOTE_ADDR") +cgilua.put "
\n" +cgilua.put ("Is persistent = "..tostring (SAPI.Info.ispersistent).."
\n") +cgilua.put ("ap="..tostring(ap).."
\n") +cgilua.put ("lfcgi="..tostring(lfcgi).."
\n") + +-- Checking Virtual Environment +local my_output = cgilua.put +cgilua.put = nil +local status, err = pcall (function () + assert (cgilua.put == nil, "cannot change cgilua.put value") +end) +cgilua.put = my_output +assert (status == true, err) + +-- Checking require +local status, err = pcall (function () require"unknown_module" end) +assert (status == false, "unknown_module loaded!") +-- assert (package == nil, "Access to package table allowed!") + +cgilua.put[[ +

+ + +]] +cgilua = nil -- cgit v1.2.3