1 <? mg.write("HTTP/1.0 200 OK") ?>
2 <? mg.write("Content-Type: text/html") ?>
6 <p>This is another example of a Lua server page, served by
7 <a href="https://github.com/civetweb/civetweb">CivetWeb web server</a>.
9 The following features are available:
12 -- functions defubed in one Lua tag should still be available in the next one
13 function print_if_available(tab, name)
15 mg.write("<li>" .. name .. "</li>\n")
21 for k,v in pairs(tab) do
22 if type(v) == "table" then
23 mg.write("<li>" .. tostring(k) .. ":</li>\n")
26 mg.write("<li>" .. tostring(k) .. " = " .. tostring(v) .. "</li>\n")
33 -- Print Lua version and available libraries
34 mg.write("<li>" .. _VERSION .. " with the following standard libraries</li>\n")
36 libs = {"string", "math", "table", "io", "os", "bit32", "utf8", "package", "coroutine", "debug"};
37 for _,n in ipairs(libs) do
38 print_if_available(_G[n], n);
41 print_if_available(sqlite3, "sqlite3 binding")
42 print_if_available(lfs,"lua file system")
46 print_if_available(_G[libname], libname .. " library")
49 -- Print connect function
50 print_if_available(connect, "connect function")
54 <p> Today is <? mg.write(os.date("%A")) ?>
58 -- for k,v in pairs(_G) do mg.write(k, '\n') end
61 mg.write("Files in " .. lfs.currentdir())
63 for f in lfs.dir(".") do
64 mg.write("<li>" .. f .. "</li>\n")
65 local at = lfs.attributes(f);