From 4220e224b5aa08edb02ae203ea7a330da40b8b9d Mon Sep 17 00:00:00 2001 From: Christian Zufferey Date: Sun, 27 Jan 2019 11:27:44 +0100 Subject: [PATCH] wip --- ZYX-html-framework/page1.html | 10 +++++++++- ZYX-html-framework/web_srv2.lua | 21 ++++++++++++++------- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/ZYX-html-framework/page1.html b/ZYX-html-framework/page1.html index 09ad16c..44992a8 100644 --- a/ZYX-html-framework/page1.html +++ b/ZYX-html-framework/page1.html @@ -10,7 +10,15 @@

ESP8266 page 1 190126.1841


Coucou c'est la page 1 !
- Retour à la home page...
+ Retour à la home page...


+ +La température est: + +<% +zout(ztemp.."oC") +%> + +
Mais il fait encore trop froid !
diff --git a/ZYX-html-framework/web_srv2.lua b/ZYX-html-framework/web_srv2.lua index 6fa12a5..926ea57 100644 --- a/ZYX-html-framework/web_srv2.lua +++ b/ZYX-html-framework/web_srv2.lua @@ -1,15 +1,25 @@ -- petit script de serveur WEB avec Active Server Page ZYX -print("\n web_srv2.lua zf190127.1045 \n") +print("\n web_srv2.lua zf190127.1127 \n") -- send a file from memory to the client; max. line length = 1024 bytes! function send_file(zclient, zfilename) if zfilename == "" then zfilename = "index.html" end if file.open(zfilename, "r") then repeat - local line=file.read('\n') + local line = file.read('\n') if line then - zclient:send(line) + if string.find(line, "<%%") then + print("start lua...") + lua_code = true + elseif string.find(line, "%%>") then + print("stop lua...") + lua_code = false + elseif lua_code then + print(line) + else + zclient:send(line) + end end until not line file.close() @@ -24,11 +34,8 @@ srv:listen(80, function(conn) conn:on("receive", function(client, request) _, _, method, path, vars = string.find(request, "([A-Z]+) (.+)?(.+) HTTP") --- print("\n\nweb_srv debug") -- print("request: \n---\n"..request.."---") --- print("method: ", method) --- print("path: ", path) --- print("vars: ", vars) +-- print("method: ", method) print("path: ", path) print("vars: ", vars) if not string.find(request, "/favicon.ico") then print("coucou")