Post your best Lua script examples here

User avatar
By dingdongclack
#35208 Hi guys!

I have a problem with my ESP-01 when I try to send the big .html file.
The ESP sends only one part of the .html file, not entire file.

Does anybody know what's the problem and how to fix it?

Thanks!

Code: Select allwifi.setmode(wifi.SOFTAP)
cfg={}
cfg.ssid="XXX"
cfg.pwd="yyy"
wifi.ap.config(cfg)
srv=net.createServer(net.TCP)

srv:listen(80,function(conn)
    conn:on("receive", function(client,payload)
          local f = file.open("index.html","r")
          if f ~= nil then
               repeat
                    local line=file.readline()
                    if line then conn:send(line) end
               until not line   
     file.close()
          else
               client:send("<html></html>")
          end
          client:close();
          collectgarbage();
          f = nil
    end)
end)
User avatar
By JeremiahLandi
#35478 Dingdongclack,

I know I have seen this code before in either an instructable or somewhere on the net.

Can you send a link to the original code you are basing this off of? If this is original work just correct me then...

Also, can you supply the html you are using?

EDIT: Found the instructable.

ESP8266 webserver serving multiple pages by breagan22
http://www.instructables.com/id/ESP8266-webserver-serving-multiple-pages/?ALLSTEPS