Trouvé le problème, c'était à nouveau une ligne dans le fichier .html qui était plus longue que 128 bytes :-( Profité pour nettoyer le code du serveur WEB ASP ZYX ;-)
This commit is contained in:
@@ -1,16 +1,7 @@
|
|||||||
-- petit script de serveur WEB avec Active Server Page ZYX
|
-- petit script de serveur WEB avec Active Server Page ZYX
|
||||||
|
-- permet d'exécuter du code LUA inline dans l'HTML !
|
||||||
|
|
||||||
print("\n web_srv2.lua zf191222.2335 \n")
|
print("\n web_srv2.lua zf200112.1530 \n")
|
||||||
|
|
||||||
-- dû refaire la commande file.readline car elle bug quand ligne longue
|
|
||||||
function zread_line()
|
|
||||||
local zline = ""
|
|
||||||
while true do
|
|
||||||
local t = file_web:read(1) if t == nil then return end
|
|
||||||
zline = zline..t
|
|
||||||
if t == "\n" then return zline end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- envoie sur le port ouvert mais depuis l'environnement global !
|
-- envoie sur le port ouvert mais depuis l'environnement global !
|
||||||
function zout(zstring)
|
function zout(zstring)
|
||||||
@@ -28,24 +19,16 @@ function send_file(zclient, zfilename)
|
|||||||
if file_web then
|
if file_web then
|
||||||
repeat
|
repeat
|
||||||
local line = file_web:readline()
|
local line = file_web:readline()
|
||||||
-- local line = file_web:read('\n')
|
|
||||||
-- local line = zread_line()
|
|
||||||
-- print("hello toto",string.len(line))
|
|
||||||
if line then
|
if line then
|
||||||
if string.find(line, "<%%") then
|
if string.find(line, "<%%") then
|
||||||
-- print("start lua...")
|
|
||||||
flag_lua_code = true -- bascule sur le code lua inline
|
flag_lua_code = true -- bascule sur le code lua inline
|
||||||
lua_code = ""
|
lua_code = ""
|
||||||
elseif string.find(line, "%%>") then
|
elseif string.find(line, "%%>") then
|
||||||
-- print("stop lua...")
|
|
||||||
flag_lua_code = false -- revient sur le code HTML
|
flag_lua_code = false -- revient sur le code HTML
|
||||||
-- print("Et voici le code lua inline:\n"..lua_code)
|
|
||||||
loadstring(lua_code)() --on exécute ici le code lua inline !
|
loadstring(lua_code)() --on exécute ici le code lua inline !
|
||||||
elseif flag_lua_code then
|
elseif flag_lua_code then
|
||||||
-- print(line)
|
|
||||||
lua_code = lua_code..line -- récupère le code lua inline
|
lua_code = lua_code..line -- récupère le code lua inline
|
||||||
else
|
else
|
||||||
-- print(line)
|
|
||||||
zclient:send(line) -- envoie le code HTML
|
zclient:send(line) -- envoie le code HTML
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -56,16 +39,10 @@ function send_file(zclient, zfilename)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
srv = net.createServer()
|
srv = net.createServer()
|
||||||
srv:listen(80, function(conn)
|
srv:listen(80, function(conn)
|
||||||
conn:on("receive", function(client, request)
|
conn:on("receive", function(client, request)
|
||||||
_, _, method, path, vars = string.find(request, "([A-Z]+) (.+)?(.+) HTTP")
|
_, _, method, path, vars = string.find(request, "([A-Z]+) (.+)?(.+) HTTP")
|
||||||
|
|
||||||
-- print("zrequest: \n---\n"..request.."---")
|
|
||||||
|
|
||||||
-- print("method: ", method) print("path: ", path) print("vars: ", vars)
|
|
||||||
|
|
||||||
if not string.find(request, "/favicon.ico") then
|
if not string.find(request, "/favicon.ico") then
|
||||||
print("coucou")
|
print("coucou")
|
||||||
if (method == nil) then
|
if (method == nil) then
|
||||||
@@ -80,7 +57,6 @@ srv:listen(80, function(conn)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
file_html=string.gsub(path, "/", "")
|
file_html=string.gsub(path, "/", "")
|
||||||
-- print("file_html: ",file_html)
|
|
||||||
send_file(client, file_html)
|
send_file(client, file_html)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|||||||
@@ -1,15 +1,18 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
|
||||||
|
<!-- ATTENTION, la longueur des lignes DOIT être <128 ! -->
|
||||||
|
|
||||||
<html lang="fr" dir="ltr">
|
<html lang="fr" dir="ltr">
|
||||||
<head>
|
<head>
|
||||||
<meta charset='utf-8' name='viewport' content='width=device-width, initial-scale=1.0'>
|
<meta charset='utf-8' name='viewport' content='width=device-width, initial-scale=1.0'>
|
||||||
<title>SonOff home page</title>
|
<title>SonOff home page</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>SonOff home page 2001011.1351</h1>
|
<h1>SonOff home page 2001012.1526</h1>
|
||||||
<a href="/">Home...</a><br>
|
<a href="/">Home...</a><br>
|
||||||
<h2>Menu:</h2>
|
<h2>Menu:</h2>
|
||||||
<h3>
|
<h3>
|
||||||
|
|
||||||
SonOff API LED
|
SonOff API LED
|
||||||
<a href="api_sonoff.html?LED=on"> On</a>
|
<a href="api_sonoff.html?LED=on"> On</a>
|
||||||
<a href="api_sonoff.html?LED=off"> Off</a><br>
|
<a href="api_sonoff.html?LED=off"> Off</a><br>
|
||||||
@@ -39,7 +42,7 @@
|
|||||||
print("On demande le setup wifi depuis le browser !")
|
print("On demande le setup wifi depuis le browser !")
|
||||||
wifi_setup_ok=(math.floor(100*node.random()))
|
wifi_setup_ok=(math.floor(100*node.random()))
|
||||||
zout("<br><br>Etes-vous vraiment certain ?<br>Si oui, faites: ")
|
zout("<br><br>Etes-vous vraiment certain ?<br>Si oui, faites: ")
|
||||||
zout('<a href="/?SetupWIFI='..wifi_setup_ok..'"> Ok</a><br><br>')
|
zout('<a href="/?SetupWIFI='..wifi_setup_ok..'"> Ok</a><br><br>')
|
||||||
end
|
end
|
||||||
%>
|
%>
|
||||||
|
|
||||||
@@ -74,7 +77,7 @@
|
|||||||
zout("<br>")
|
zout("<br>")
|
||||||
%>
|
%>
|
||||||
|
|
||||||
<%
|
<%
|
||||||
if zRELAY ~= nil then
|
if zRELAY ~= nil then
|
||||||
zout("Etat du RELAY:<nsp>")
|
zout("Etat du RELAY:<nsp>")
|
||||||
if gpio.read(zRELAY) == 0 then zout("OFF") else zout("ON") end
|
if gpio.read(zRELAY) == 0 then zout("OFF") else zout("ON") end
|
||||||
@@ -85,7 +88,9 @@
|
|||||||
<%
|
<%
|
||||||
a,b,c = wifi.sta.getip()
|
a,b,c = wifi.sta.getip()
|
||||||
if a ~= nil then
|
if a ~= nil then
|
||||||
zout("<br><br>IP: "..a.." MASK: "..b.." GATEWAY: "..c.."<br>")
|
zout("<br>IP: "..a.."<br>")
|
||||||
|
zout("MASK: "..b.."<br>")
|
||||||
|
zout("GATEWAY: "..c.."<br>")
|
||||||
end
|
end
|
||||||
collectgarbage() zout("RAM: "..node.heap())
|
collectgarbage() zout("RAM: "..node.heap())
|
||||||
%>
|
%>
|
||||||
|
|||||||
Reference in New Issue
Block a user