lua code on esp-01 running 0.9.4 20141222
wifi.setmode(3)
wifi.setmode(wifi.STATION)
wifi.sta.config("xxxxx","xxxxxxxx")
s=net.createServer(net.TCP)
s:listen(80,function(c)
c:on("receive",function(c,pl)
for v,i in pairs{3,4} do
gpio.mode(i,gpio.OUTPUT)
print(i,pl)
if string.find(pl,"gpio"..i.."=0") then gpio.write(i,0) end
if string.find(pl,"gpio"..i.."=1") then gpio.write(i,1) end
end
c:send("\nTMR:"..tmr.now().." MEM:"..node.heap())
c:on("sent",function(c) c:close() end)
end)
end)
My Ajax call from the raspberry pi looks like this:
$.ajax({
url: 'http://192.168.0.179',
type: 'POST',
dataType:'Type',
beforeSend: function (xhr) {xhr.setRequestHeader ("Authorization", "Basic xxxx")},
error : function() {
alert("error")},
success: function(data){
alert("data")},
})
but as expected in the chrome JavaScript console I get: XMLHttpRequest cannot load http://192.168.0.179/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://192.168.0.38:8000' is therefore not allowed access.. I have assumed I need to do a before Send Authorization request, however considering I never set eyes on lua before yesterday I would really appreciate some assistance with the luya code, thanks and Merry Christmas Toshi