mg.write("HTTP/1.0 200 OK") ?>
 mg.write("Content-Type: text/html") ?>
This is another example of a Lua server page, served by
Civetweb web server.
The following features are available:
  -- function in one Lua tag should still be available in the next one
  function test(tab, name)
    if tab then
      mg.write("- " .. name .. "
 ")
    end
  end
  function recurse(tab)
    mg.write("")
    for k,v in pairs(tab) do      
      if type(v) == "table" then
        mg.write("- " .. tostring(k) .. ":
 ")
        recurse(v)
      else
        mg.write("- " .. tostring(k) .. " = " .. tostring(v) .. "
 ")        
      end
    end
    mg.write("
")
  end
?>
  mg.write("- " .. _VERSION .. " with the following standard libraries
 ")
  mg.write("")
  libs = {"string", "math", "table", "io", "os", "bit32", "package", "coroutine", "debug"};
  for _,n in ipairs(libs) do
    test(_G[n], n);
  end
  mg.write("
")
  test(sqlite3, "sqlite3 binding")
  test(lfs,"lua file system")
  
  libname = "mg"
  test(_G[libname], libname .. " library")
  recurse(_G[libname])
?>
 Today is  mg.write(os.date("%A")) ?>
  -- for k,v in pairs(_G) do mg.write(k, '\n') end  
  if lfs then    
    mg.write("Files in " .. lfs.currentdir())
    mg.write("
")
    for f in lfs.dir(".") do
      mg.write("- " .. f .. "
 ")
      local at = lfs.attributes(f);
      recurse(at)
    end
    mg.write("
")
  end
?>