args.lua 1007 B

1234567891011121314151617181920212223242526
  1. return function (connection, req, args)
  2. dofile("httpserver-header.lc")(connection, 200, 'html')
  3. connection:send([===[
  4. <!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>Arguments by GET</title></head><body><h1>Arguments by GET</h1>
  5. ]===])
  6. if args.submit == nil then
  7. connection:send([===[
  8. <form method="GET">
  9. First name:<br><input type="text" name="firstName"><br>
  10. Last name:<br><input type="text" name="lastName"><br>
  11. <input type="radio" name="sex" value="male" checked>Male<input type="radio" name="sex" value="female">Female<br>
  12. <input type="submit" name="submit" value="Submit">
  13. </form>
  14. ]===])
  15. else
  16. connection:send("<h2>Received the following values:</h2><ul>")
  17. for name, value in pairs(args) do
  18. connection:send('<li><b>' .. name .. ':</b> ' .. tostring(value) .. "<br></li>\n")
  19. end
  20. connection:send("</ul>\n")
  21. end
  22. connection:send("</body></html>")
  23. end