Mon petit serveur WEB ASP fonctionne super bien, pas de fuite mémoire :-)
This commit is contained in:
@@ -7,11 +7,11 @@
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>ESP8266 home page 190126.1836</h1>
|
||||
<h1>ESP8266 home page 190127.1444</h1>
|
||||
<h2>Différentes pages HTML:</h2>
|
||||
<h3>
|
||||
<a href="page1.html">Page 1</a><br>
|
||||
<a href="page2.html">Page 2</a><br>
|
||||
<a href="page1.html">Page 1, affichage de la température dynamique en code Lua inline.</a><br>
|
||||
<a href="page2.html">Page 2, tableau dynamique écrit en Lua inline.</a><br>
|
||||
<a href="page_qui_existe_pag.html">Page qui n'existe pas !</a><br>
|
||||
</h3>
|
||||
</body>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>ESP8266 page 1 190126.1841</h1>
|
||||
<h1>ESP8266 page 1 190127.1445</h1>
|
||||
<br>
|
||||
Coucou c'est la page 1 !<br>
|
||||
<a href="/">Retour à la home page...</a><br><br><br>
|
||||
|
||||
@@ -1,17 +1,51 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr" dir="ltr">
|
||||
|
||||
<head>
|
||||
<meta charset='utf-8' name='viewport' content='width=device-width, initial-scale=1.0'>
|
||||
<title>ESP8266 page 2</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>ESP8266 page 2 190126.1840</h1>
|
||||
<br>
|
||||
Coucou c'est la page 2 !<br>
|
||||
<a href="/">Retour à la home page...</a><br>
|
||||
|
||||
</body>
|
||||
<head>
|
||||
<meta charset='utf-8' name='viewport' content='width=device-width, initial-scale=1.0'>
|
||||
<title>ESP8266 page 2</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>ESP8266 page 2 190127.1449</h1>
|
||||
<br>
|
||||
Coucou c'est la page 2 !<br>
|
||||
<a href="/">Retour à la home page...</a><br><br><br>
|
||||
|
||||
Voici un tableau dynamique écrit en Lua inline.<br><br>
|
||||
|
||||
Le code Lua pour créer ce tableau se trouve dans le code HTML de cette page et est exécuté sur le NodeMCU.<br>
|
||||
Les données du tableau viennent du NodeMCU !<br><br>
|
||||
|
||||
<%
|
||||
-- création du tableau sur le NodeMCUjuste juste pour la démo ici !
|
||||
zmac_adrs={}
|
||||
zmac_adrs["b8:d7:af:a6:bd:86"]={["zname"]="S7 zf", ["zrssi"]=45, ["ztime"]="12:03:36"}
|
||||
zmac_adrs["cc:c0:79:7d:f5:d5"]={["zname"]="S7 Mélanie", ["zrssi"]=50, ["ztime"]="14:23:46"}
|
||||
zmac_adrs["5c:f9:38:a1:f7:f0"]={["zname"]="MAC zf", ["zrssi"]=40, ["ztime"]="11:53:16"}
|
||||
zmac_adrs["d8:30:62:5a:d6:3a"]={["zname"]="IMAC Maman", ["zrssi"]=55, ["ztime"]="17:07:23"}
|
||||
%>
|
||||
|
||||
<table border='1'>
|
||||
<tr>
|
||||
<th>MAC</th><th>Name</th><th>RSSI</th><th>Time</th>
|
||||
</tr>
|
||||
<%
|
||||
for k, v in pairs(zmac_adrs) do
|
||||
zout("<tr>\n")
|
||||
zout("\t<td>" .. k .. "</td>\n")
|
||||
zout("\t<td>" .. tostring(zmac_adrs[k]["zname"]) .. "</td>\n")
|
||||
zout("\t<td>" .. tostring(zmac_adrs[k]["zrssi"]) .. "</td>\n")
|
||||
zout("\t<td>" .. tostring(zmac_adrs[k]["ztime"]) .. "</td>\n")
|
||||
zout("</tr>\n")
|
||||
end
|
||||
%>
|
||||
</table>
|
||||
|
||||
<%
|
||||
-- libère la mémoire du tableau sur le NodeMCU qui avait été créé pour la démo ici !
|
||||
zmac_adrs=nil
|
||||
%>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,35 +1,37 @@
|
||||
-- petit script de serveur WEB avec Active Server Page ZYX
|
||||
-- pour l'instant la partie ASP n'est que mono tâche !
|
||||
|
||||
print("\n web_srv2.lua zf190127.1340 \n")
|
||||
print("\n web_srv2.lua zf190127.1458 \n")
|
||||
|
||||
ztemp=12
|
||||
|
||||
-- send a file from memory to the client; max. line length = 1024 bytes!
|
||||
-- envoie sur le port ouvert mais depuis l'environnement global !
|
||||
function zout(zstring)
|
||||
zzclient:send(zstring) -- envoie le résultat du code lua inline
|
||||
end
|
||||
|
||||
-- envoie un fichier HTML sur le port. ATTENTION: longueur de la ligne maximale de 1'024 bytes !
|
||||
function send_file(zclient, zfilename)
|
||||
zzclient=zclient
|
||||
function zout(zstring)
|
||||
zzclient:send(zstring)
|
||||
end
|
||||
|
||||
zzclient = zclient -- export le port sur l'environnement global !
|
||||
if zfilename == "" then zfilename = "index.html" end
|
||||
if file.open(zfilename, "r") then
|
||||
repeat
|
||||
local line = file.read('\n')
|
||||
if line then
|
||||
if string.find(line, "<%%") then
|
||||
print("start lua...")
|
||||
flag_lua_code = true
|
||||
-- print("start lua...")
|
||||
flag_lua_code = true -- bascule sur le code lua inline
|
||||
lua_code = ""
|
||||
elseif string.find(line, "%%>") then
|
||||
print("stop lua...")
|
||||
flag_lua_code = false
|
||||
print("Et voici le code lua inline:\n"..lua_code)
|
||||
loadstring(lua_code)() --on exécute ici le code lua inline !
|
||||
-- print("stop lua...")
|
||||
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 !
|
||||
elseif flag_lua_code then
|
||||
-- print(line)
|
||||
lua_code =lua_code..line
|
||||
lua_code = lua_code..line -- récupère le code lua inline
|
||||
else
|
||||
zout(line)
|
||||
zclient:send(line) -- envoie le code HTML
|
||||
end
|
||||
end
|
||||
until not line
|
||||
|
||||
Reference in New Issue
Block a user