handler.lua 432 B

12345678910111213141516
  1. function handle_request(env)
  2. uhttpd.send("Status: 200 OK\r\n")
  3. uhttpd.send("Content-Type: text/html\r\n\r\n")
  4. uhttpd.send("<h1>Headers</h1>\n")
  5. for k, v in pairs(env.headers) do
  6. uhttpd.send(string.format("<strong>%s</strong>: %s<br>\n", k, v))
  7. end
  8. uhttpd.send("<h1>Environment</h1>\n")
  9. for k, v in pairs(env) do
  10. if type(v) == "string" then
  11. uhttpd.send(string.format("<code>%s=%s</code><br>\n", k, v))
  12. end
  13. end
  14. end