So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By rohansagar4
#62265 i have a code that works fine until i add the line
<button style="width=200px;height=200px">on </button>
i have an error at 200px
Code: Select allwifi.setmode(wifi.STATION)
wifi.sta.config("my_ssid","my_password")
print(wifi.sta.getip())
led1 = 1
led2 = 2
gpio.mode(led1, gpio.OUTPUT)
gpio.mode(led2, gpio.OUTPUT)
srv=net.createServer(net.TCP)
srv:listen(80,function(conn)
    conn:on("receive", function(client,request)
        local buf = "";
        local _, _, method, path, vars = string.find(request, "([A-Z]+) (.+)?(.+) HTTP");
        if(method == nil)then
            _, _, method, path = string.find(request, "([A-Z]+) (.+) HTTP");
        end
        local _GET = {}
        if (vars ~= nil)then
            for k, v in string.gmatch(vars, "(%w+)=(%w+)&*") do
                _GET[k] = v
            end
        end
        buf = buf.."<h1> leds </h1>";
        buf = buf.."<p>Light&nbsp<a href=\"?pin=ON1\"><button style="width:200px;height=200px;">OFF</button></a>&nbsp;<a href=\"?pin=OFF1\"><button>ON</button></a></p>";
        buf = buf.."<p>Fan   &nbsp;  &nbsp;<a href=\"?pin=ON2\"><button>OFF</button></a>&nbsp;<a href=\"?pin=OFF2\"><button>ON</button></a></p>";
        local _on,_off = "",""
        if(_GET.pin == "ON1")then
              gpio.write(led1, gpio.HIGH);
        elseif(_GET.pin == "OFF1")then
              gpio.write(led1, gpio.LOW);
        elseif(_GET.pin == "ON2")then
              gpio.write(led2, gpio.HIGH);
        elseif(_GET.pin == "OFF2")then
              gpio.write(led2, gpio.LOW);
        end
        client:send(buf);
        client:close();
        collectgarbage();
    end)
end)




the error is " lua: init.lua:23: malformed number near '200px' "
i am a tootal newbie .. plzzzz help me