No need to yield. Conditionally show form. Updated title.
This commit is contained in:
parent
066b602444
commit
d31b2d2c89
@ -1,26 +1,25 @@
|
|||||||
return function (connection, args)
|
return function (connection, req, args)
|
||||||
dofile("httpserver-header.lc")(connection, 200, 'html')
|
dofile("httpserver-header.lc")(connection, 200, 'html')
|
||||||
connection:send([===[
|
connection:send([===[
|
||||||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>Arguments</title></head><body><h1>Arguments</h1>
|
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>Arguments by GET</title></head><body><h1>Arguments by GET</h1>
|
||||||
<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>
|
|
||||||
]===])
|
]===])
|
||||||
coroutine.yield()
|
|
||||||
|
|
||||||
if args["submit"] ~= nil then
|
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>")
|
connection:send("<h2>Received the following values:</h2><ul>")
|
||||||
coroutine.yield()
|
|
||||||
for name, value in pairs(args) do
|
for name, value in pairs(args) do
|
||||||
connection:send('<li><b>' .. name .. ':</b> ' .. tostring(value) .. "<br></li>\n")
|
connection:send('<li><b>' .. name .. ':</b> ' .. tostring(value) .. "<br></li>\n")
|
||||||
coroutine.yield()
|
|
||||||
end
|
end
|
||||||
|
connection:send("</ul>\n")
|
||||||
end
|
end
|
||||||
|
connection:send("</body></html>")
|
||||||
connection:send("</ul>\n</body></html>")
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user