function webServer() if srv~=nil then srv:close() srv = nil; end -- Webserver srv=net.createServer(net.TCP); srv:listen(80,function(conn) conn:on("receive", function(client, request) client:send(generateHTML(request)); client:close(); collectgarbage(); end) end) end
function generateHTML() output = [[ <html> <head> <title>]]..sensorName.. " " ..sensorType ..[[</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> .align { width:120px; display: inline-block; } </style> </head> <body> <div style="max-width: 400px; margin: auto; "> <h2>]]..sensorName.." "..sensorType..[[</h2> </div> </body> </html> ]]; return output; end