Fix example server-side scripts to work on new nodemcu-firmware. Specifically, call coroutine.yield() after each connection:send() except the last one, since we can no longer queue sends.
This commit is contained in:
@@ -1,26 +1,25 @@
|
||||
return function (connection, args)
|
||||
connection:send("HTTP/1.0 200 OK\r\nContent-Type: text/html\r\nCache-Control: private, no-store\r\n\r\n")
|
||||
connection:send('<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>Arguments</title></head>')
|
||||
connection:send('<body>')
|
||||
connection:send('<h1>Arguments</h1>')
|
||||
dofile("httpserver-header.lc")(connection, 200, 'html')
|
||||
|
||||
local form = [===[
|
||||
connection:send([===[
|
||||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>Arguments</title></head><body><h1>Arguments</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" value="Submit">
|
||||
<input type="submit" name="submit" value="Submit">
|
||||
</form>
|
||||
]===]
|
||||
]===])
|
||||
coroutine.yield()
|
||||
|
||||
connection:send(form)
|
||||
|
||||
connection:send('<h2>Received the following values:</h2>')
|
||||
connection:send("<ul>\n")
|
||||
for name, value in pairs(args) do
|
||||
connection:send('<li><b>' .. name .. ':</b> ' .. tostring(value) .. "<br></li>\n")
|
||||
if args["submit"] ~= nil then
|
||||
connection:send("<h2>Received the following values:</h2><ul>")
|
||||
coroutine.yield()
|
||||
for name, value in pairs(args) do
|
||||
connection:send('<li><b>' .. name .. ':</b> ' .. tostring(value) .. "<br></li>\n")
|
||||
coroutine.yield()
|
||||
end
|
||||
end
|
||||
|
||||
connection:send("</ul>\n")
|
||||
connection:send('</body></html>')
|
||||
connection:send("</ul>\n</body></html>")
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user