diff --git a/README.md b/README.md index aadf9c5..8162cf3 100644 --- a/README.md +++ b/README.md @@ -78,11 +78,6 @@ A (very) simple web server written in Lua for the ESP8266 running the NodeMCU fi For example, if the client requests _http://2.2.2.2/foo.lua?color=red_ then the server will execute the function in your Lua script _foo.lua_ and pass in _connection_ and _args_, where _args.color = "red"_. - If you are going to be sending lots (as in over a KB) of data in your script, you should yield the thread/coroutine - every now and then in order to avoid overflowing the send buffer in the microcontroller. Use: - - coroutine.yield() - Look at the included example scripts for more ideas. ### Example: Garage door opener diff --git a/http/file_list.lua b/http/file_list.lua index 9e92a23..6879900 100644 --- a/http/file_list.lua +++ b/http/file_list.lua @@ -2,7 +2,6 @@ return function (connection, req, 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('Server File Listing') connection:send('') - coroutine.yield() connection:send('

Server File Listing

') local remaining, used, total=file.fsinfo() @@ -20,8 +19,6 @@ return function (connection, req, args) if isHttpFile then local url = string.match(name, ".*/(.*)") connection:send('
  • ' .. url .. " (" .. size .. " bytes)
  • \n") - -- this list could be very long, so we'll yield in order to avoid overflowing the send buffer. - coroutine.yield() end end connection:send("\n") diff --git a/http/node_info.lua b/http/node_info.lua index 86e55eb..8ab0df9 100644 --- a/http/node_info.lua +++ b/http/node_info.lua @@ -4,14 +4,16 @@ local function sendHeader(connection) end local function sendAttr(connection, attr, val) - connection:send("
  • ".. attr .. ": " .. val .. "
  • \n") + if val then + connection:send("
  • ".. attr .. ": " .. val .. "
  • \n") + end end return function (connection, req, args) collectgarbage() sendHeader(connection) connection:send('A Lua script sample

    Node info