forked from marcoskirsch/nodemcu-httpserver
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathargs.lua
More file actions
25 lines (23 loc) · 1007 Bytes
/
Copy pathargs.lua
File metadata and controls
25 lines (23 loc) · 1007 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
return function (connection, req, args)
dofile("httpserver-header.lc")(connection, 200, 'html')
connection:send([===[
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>Arguments by GET</title></head><body><h1>Arguments by GET</h1>
]===])
if args.submit == nil then
connection:send([===[
<form method="GET">
First name:<br><input type="text" name="firstName"><br>
Last name:<br><input type="text" name="lastName"><br>
<input type="radio" name="sex" value="male" checked>Male<input type="radio" name="sex" value="female">Female<br>
<input type="submit" name="submit" value="Submit">
</form>
]===])
else
connection:send("<h2>Received the following values:</h2><ul>")
for name, value in pairs(args) do
connection:send('<li><b>' .. name .. ':</b> ' .. tostring(value) .. "<br></li>\n")
end
connection:send("</ul>\n")
end
connection:send("</body></html>")
end