如何修改這個程序
led3 = 2
gpio.mode(led1, gpio.OUTPUT) ?
gpio.mode(led2, gpio.OUTPUT) ?
gpio.mode(led3, 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>k</h1>"; ?
??????? buf = buf.."<p>quiet <a href=\"?pin=ON1\"><button>ON<tton></a> <a href=\"?pin=OFF1\"><button>OFF<tton></a></p>"; ?
??????? buf = buf.."<p>tixing<a href=\"?pin=ON2\"><button>ON<tton></a> <a href=\"?pin=OFF2\"><button>OFF<tton></a></p>"; ?
??????? buf = buf.."<p>fcheng<a href=\"?pin=ON3\"><button>ON<tton></a> <a href=\"?pin=OFF3\"><button>OFF<tton></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); ?
??????? elseif(_GET.pin == "ON3")then ?
????????????? gpio.write(led3, gpio.HIGH); ?
??????? elseif(_GET.pin == "OFF3")then ?
????????????? gpio.write(led3, gpio.LOW); ?
??????? end ?
??????? client:send(buf); ?
??????? client:close(); ?
??????? collectgarbage(); ?
??? end) ?
end)
我想問一下這個程序中怎樣把加粗的地方改成中文后輸出是中文,我有試過把加粗那一句改為中文后出現了亂碼,