If I make a single page server it doesn't seem to go down...
Here's my code
local temperature
local t=require("ds18b20")
t.setup(5)
addrs=t.addrs()
function srvReceive(client, request)
local buf = "HTTP/1.1 200 OK\r\nContent-Type: text/json\r\n\r\n"
if string.find(request, "/ ") then
Sendfile(client, "ds18b20.html")
elseif (string.find(request, "/temperature ")) then
client:send(buf .. t.read(addrs[1],t.F))
client:close()
elseif string.find(request, "/info ") then
buf = buf .. "{ \"description\":\""..device_location.."\",\"type\":\"ds18b20\" }"
client:send(buf)
client:close()
else
Sendfile(client, "404.html")
end
request = nil
buf = nil
collectgarbage()
end
function srvListen(conn)
conn:on("receive", srvReceive)
end
if srv ~= nil then
node.restart()
end
print("Setting up mdns")
mdns.register("nodemcu"..node.chipid(), { description=device_location, service="nodemcu", port=80, type="ds18b20", chipid=node.chipid() })
print("Setting up webserver")
dofile("sendfile.lua")
srv = nil
srv=net.createServer(net.TCP)
srv:listen(80,srvListen)