Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- gpio.mode(5, gpio.INPUT)
- srv=net.createServer(net.TCP)
- srv:listen(80,function(conn)
- print(payload)
- conn:on("receive",function(conn,payload)
- print(payload)
- if ( gpio.read(5) == 0 ) then
- reply = "GPIO14 (5) is 0"
- elseif ( gpio.read(5) == 1 ) then
- reply = "GPIO14 (5) is 1"
- else
- reply = "GPIO14 (5) is ERR"
- end
- payloadLen = string.len(reply)
- print(payloadLen)
- conn:send("HTTP/1.1 200 OK\r\n")
- conn:send("Content-Length:" .. tostring(payloadLen) .. "\r\n")
- conn:send("Connection:close\r\n\r\n")
- conn:send(reply)
- end)
- conn:on("sent",function(conn)
- conn:close()
- end)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement