Gros problème, je me suis aperçu que la commande file.readline dans web_srv2.lua a un gros bug quand une ligne est longue, j'ai dû la réécrire et testée dans cat.lua. Me reste encore à corriger web_srv2.lua
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
-- Scripts à charger après le boot pour démarrer le core system
|
||||
|
||||
print("\n boot.lua zf191030.2012 \n")
|
||||
print("\n boot.lua zf191124.1920 \n")
|
||||
|
||||
function boot()
|
||||
--f= "led_rgb.lua" if file.exists(f) then dofile(f) end
|
||||
f= "telnet_srv2.lua" if file.exists(f) then dofile(f) end
|
||||
f= "wifi_init.lua" if file.exists(f) then dofile(f) end
|
||||
--f= "web_ide2.lua" if file.exists(f) then dofile(f) end
|
||||
--ff= "web_srv2.lua" if file.exists(f) then dofile(f) end
|
||||
--f= "web_srv2.lua" if file.exists(f) then dofile(f) end
|
||||
end
|
||||
boot()
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
-- Scripts à charger après le boot pour démarrer son projet
|
||||
|
||||
print("\n boot2.lua zf191030.2038 \n")
|
||||
print("\n boot2.lua zf191124.1922 \n")
|
||||
|
||||
function boot2()
|
||||
second_chance=nil initz=nil boot=nil
|
||||
@@ -27,7 +27,8 @@ function boot2()
|
||||
f= "secrets_project.lua" if file.exists(f) then dofile(f) end
|
||||
f= "set_time.lua" if file.exists(f) then dofile(f) end
|
||||
collectgarbage()
|
||||
f= "b.lua" if file.exists(f) then dofile(f) end
|
||||
--- f= "b.lua" if file.exists(f) then dofile(f) end
|
||||
f= "web_srv2.lua" if file.exists(f) then dofile(f) end
|
||||
|
||||
f=nil
|
||||
|
||||
|
||||
@@ -1,18 +1,22 @@
|
||||
-- fonction cat() pour afficher le contenu d'un fichier dans la flash
|
||||
print("\n cat.lua zf192026.0858 \n")
|
||||
print("\n cat.lua zf191124.2204 \n")
|
||||
|
||||
function zread_line()
|
||||
local zline = ""
|
||||
while true do
|
||||
local t = zf:read(1) if t == nil then return end
|
||||
zline = zline..t
|
||||
if t == "\n" then return string.sub(zline,1,string.len(zline)-1) end
|
||||
end
|
||||
end
|
||||
|
||||
function cat(zfile)
|
||||
print("\n"..zfile.."\n-------------------------------")
|
||||
|
||||
zfilei = file.open(zfile, "r")
|
||||
i=1
|
||||
zline=file.readline()
|
||||
repeat
|
||||
-- print(i..": "..string.sub(zline,1,string.len(zline)-1))
|
||||
print(string.sub(zline,1,string.len(zline)-1))
|
||||
i=i+1 zline=file.readline()
|
||||
until zline== nil
|
||||
file.close(zfilei)
|
||||
|
||||
zf = file.open(zfile, "r")
|
||||
while true do
|
||||
zline = zread_line() if zline == nil then break end
|
||||
print(zline)
|
||||
end
|
||||
zf:close()
|
||||
print("-------------------------------")
|
||||
end
|
||||
|
||||
@@ -15,7 +15,7 @@ function send_file(zclient, zfilename)
|
||||
zclient:send("HTTP/1.1 200 OK\n")
|
||||
zclient:send("Content-Type: text/html\n\n")
|
||||
zzclient = zclient -- export le port sur l'environnement global !
|
||||
if zfilename == "" then zfilename = "z_index.html" end
|
||||
if zfilename == "" then zfilename = "z_index.html" end
|
||||
file_web = file.open(zfilename, "r")
|
||||
if file_web then
|
||||
repeat
|
||||
@@ -34,10 +34,11 @@ function send_file(zclient, zfilename)
|
||||
-- print(line)
|
||||
lua_code = lua_code..line -- récupère le code lua inline
|
||||
else
|
||||
print(line)
|
||||
zclient:send(line) -- envoie le code HTML
|
||||
end
|
||||
end
|
||||
until not line
|
||||
until not line
|
||||
file_web:close() file_web = nil
|
||||
else
|
||||
zclient:send("<html><h1>"..zfilename.." not found - 404 error</h1><a href='/'>Home</a><br></html>")
|
||||
@@ -49,11 +50,11 @@ srv = net.createServer()
|
||||
srv:listen(80, function(conn)
|
||||
conn:on("receive", function(client, request)
|
||||
_, _, 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
|
||||
print("coucou")
|
||||
if (method == nil) then
|
||||
@@ -69,10 +70,8 @@ srv:listen(80, function(conn)
|
||||
end
|
||||
file_html=string.gsub(path, "/", "")
|
||||
-- print("file_html: ",file_html)
|
||||
send_file(client, file_html)
|
||||
send_file(client, file_html)
|
||||
end
|
||||
end)
|
||||
conn:on("sent", function(c) c:close() end)
|
||||
end)
|
||||
|
||||
|
||||
|
||||
26
WIFI_sniffer/cret_project/wifi_config.html
Normal file
26
WIFI_sniffer/cret_project/wifi_config.html
Normal file
@@ -0,0 +1,26 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr" dir="ltr">
|
||||
|
||||
<head>
|
||||
<meta charset='utf-8' name='viewport' content='width=device-width, initial-scale=1.0'>
|
||||
<title>WIFI config</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>WIFI config 191124.1931</h1>
|
||||
<br>
|
||||
Coucou c'est la page 1 !<br>
|
||||
<a href="/">Retour à la home page...</a><br><br><br>
|
||||
|
||||
La température est:
|
||||
|
||||
<%
|
||||
ztemp=ztemp+1
|
||||
zout(ztemp.."°C")
|
||||
%>
|
||||
|
||||
<br>Mais il fait encore trop froid !<br>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -7,15 +7,27 @@
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>ESP8266 home page 190727.0941</h1>
|
||||
<h1>ESP8266 home page 191124.2054</h1>
|
||||
<h2>Différentes pages HTML:</h2>
|
||||
<h3>
|
||||
<a href="z_page1.html">Page 1, affichage de la température dynamique en code Lua inline.</a><br>
|
||||
<a href="z_page2.html">Page 2, tableau dynamique écrit en Lua inline.</a><br>
|
||||
<a href="z_page3.html">Page 3, affichage du capteur non linéaire corrigé.</a><br>
|
||||
<a href="z_page4.html?field1=11&field2=12&field3=13">Page 4, test de récupération d'arguments pour un web service.</a><br>
|
||||
<a href="api_hub_temp.html?field1=11&field2=12&field3=13">API HUB Temp, test d'un web service hub de mesures de température.</a><br>
|
||||
toto
|
||||
<a href="z_page4.html?field1=11&field2=12&field3=13">Page 4, toto tutu titi toto tutu titi toto tutu titi pour un web service.</a><br>
|
||||
tutu
|
||||
tutu2
|
||||
tutu3
|
||||
|
||||
test de récupération d'arguments
|
||||
?field1=11&field2=12&field3=13
|
||||
|
||||
<a href="api_hub_temp.html?field1=11&field2=12&field3=13">API HUB Temp,
|
||||
test d'un web service hub de mesures de température.</a><br>
|
||||
tata
|
||||
<a href="disp_temp.html">Affichage des températures, affiche les températures mesurées.</a><br>
|
||||
<a href="wifi_config.html">WIFI configuration.</a><br>
|
||||
|
||||
<a href="page_qui_existe_pag.html">Page qui n'existe pas !</a><br>
|
||||
</h3>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user