page5.lua 881 B

12345678910111213141516171819202122232425262728
  1. -- This test checks the Lua functions:
  2. -- get_var, get_cookie, md5, url_encode
  3. now = os.time()
  4. cookie_name = "civetweb-test-page4"
  5. if mg.request_info.http_headers.Cookie then
  6. cookie_value = tonumber(mg.get_cookie(mg.request_info.http_headers.Cookie, cookie_name))
  7. end
  8. mg.write("HTTP/1.0 200 OK\r\n")
  9. mg.write("Connection: close\r\n")
  10. mg.write("Content-Type: text/html; charset=utf-8\r\n")
  11. mg.write("Cache-Control: max-age=0, must-revalidate\r\n")
  12. if not cookie_value then
  13. mg.write("Set-Cookie: " .. cookie_name .. "=" .. tostring(now) .. "\r\n")
  14. end
  15. mg.write("\r\n")
  16. mg.write("<html>\r\n<head><title>Civetweb Lua script test page 5</title></head>\r\n<body>\r\n")
  17. mg.write("<p>Test of Civetweb Lua Import Functions:</p>\r\n");
  18. mg.write("<pre>\r\n");
  19. -- begin of page
  20. require 'lxp'
  21. -- end of page
  22. mg.write("</pre>\r\n</body>\r\n</html>\r\n")