diff --git a/WEB/web_srv_mini.lua b/WEB/web_srv_mini.lua new file mode 100644 index 0000000..d887d56 --- /dev/null +++ b/WEB/web_srv_mini.lua @@ -0,0 +1,13 @@ +-- petit script de serveur WEB minimaliste + +print("\n web_srv_mini.lua zf190127.1017 \n") + +srv = net.createServer(net.TCP) + +srv:listen(80, function(conn) + conn:on("receive", function(client, request) + print(request) + client:send("

ESP8266
Server is working!

"..tmr.now()) + end) + conn:on("sent", function(c) c:close() end) +end) diff --git a/ZYX-html-framework/a_test_ram.lua b/ZYX-html-framework/a_test_ram.lua index f876967..9efa3cd 100644 --- a/ZYX-html-framework/a_test_ram.lua +++ b/ZYX-html-framework/a_test_ram.lua @@ -1,7 +1,7 @@ -- Scripts pour tester l'occupation méroire des différents modules -- source: -print("\n a_test_ram.lua zf190126.1845 \n") +print("\n a_test_ram.lua zf190127.1014 \n") test_ram_alarm1=tmr.create() test_ram_alarm2=tmr.create() diff --git a/ZYX-html-framework/web_srv2.lua b/ZYX-html-framework/web_srv2.lua index f1de64d..6fa12a5 100644 --- a/ZYX-html-framework/web_srv2.lua +++ b/ZYX-html-framework/web_srv2.lua @@ -1,6 +1,6 @@ -- petit script de serveur WEB avec Active Server Page ZYX -print("\n web_srv2.lua zf190127.0145 \n") +print("\n web_srv2.lua zf190127.1045 \n") -- send a file from memory to the client; max. line length = 1024 bytes! function send_file(zclient, zfilename) @@ -14,56 +14,40 @@ function send_file(zclient, zfilename) until not line file.close() else - zclient:send("

"..zfilename.." not found - 404 error.

Home
") + zclient:send("

"..zfilename.." not found - 404 error

Home
") end - zfilename = nil - zclient = nil - line = nil - file = nil - end -srv = net.createServer(net.TCP,10) +srv = net.createServer() 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) - ---[[ - if not string.find(request, "/favicon.ico") then - print("coucou") - if (method == nil) then - _, _, method, path = string.find(request, "([A-Z]+) (.+) HTTP") - end - _GET = {} - if (vars ~= nil) then - for k, v in string.gmatch(vars, "(%w+)=(%w+)&*") do - _GET[k] = v - print(k..": "..v) - end - end - file_html=string.gsub(path, "/", "") - print("file_html: ",file_html) --- send_file(conn, file_html) --- send_file = nil - -]] - - - client:send("

ESP8266
Server is working!

"..tmr.now().."\n\n") + 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) --- end - - - end) - conn:on("sent", function(c) c:close() end) + if not string.find(request, "/favicon.ico") then + print("coucou") + if (method == nil) then + _, _, method, path = string.find(request, "([A-Z]+) (.+) HTTP") + end + _GET = {} + if (vars ~= nil) then + for k, v in string.gmatch(vars, "(%w+)=(%w+)&*") do + _GET[k] = v + print(k..": "..v) + end + end + file_html=string.gsub(path, "/", "") + -- print("file_html: ",file_html) + send_file(client, file_html) + end + end) + conn:on("sent", function(c) c:close() end) end) - + diff --git a/ZYX-html-framework/web_srv_test.lua b/ZYX-html-framework/web_srv_test.lua deleted file mode 100644 index 0fa3d35..0000000 --- a/ZYX-html-framework/web_srv_test.lua +++ /dev/null @@ -1,17 +0,0 @@ --- petit script de serveur WEB pour tester les fuite mémoire - -print("\n web_srv_test.lua zf190126.2014 \n") - -sv = net.createServer() - -function receiver(sck, data) - print(data) - sck:close() -end - -sv:listen(80, function(conn) - conn:on("receive", receiver) - conn:send("

ESP8266
Server is working!

"..tmr.now().."\n\n") -end) - - diff --git a/ZYX-html-framework/web_srv_test2.lua b/ZYX-html-framework/web_srv_test2.lua deleted file mode 100644 index 879b550..0000000 --- a/ZYX-html-framework/web_srv_test2.lua +++ /dev/null @@ -1,31 +0,0 @@ --- petit script de serveur WEB pour tester les fuite mémoire - -print("\n web_srv_test2.lua zf190126.2335 \n") - -function receiver(sck, data) - print(data) - sck:close() -end - -function zclose(sck, data) - print(data) - sck:close() -end - -sv = net.createServer() -sv:listen(80, function(conn) - - conn:on("receive", function(client, request) - print(request) --- client:close() - conn:send("

ESP8266
Server is working!

"..tmr.now().."\n\n") --- conn:on("sent", function(c) c:close() end) - conn:on("sent", zclose) -end) - conn:on("sent", nil) - - --- conn:on("sent", function(c) c:close() end) -end) - - diff --git a/ZYX-html-framework/web_srv_test3.lua b/ZYX-html-framework/web_srv_test3.lua deleted file mode 100644 index 4e81ff2..0000000 --- a/ZYX-html-framework/web_srv_test3.lua +++ /dev/null @@ -1,16 +0,0 @@ --- petit script de serveur WEB pour tester les fuite mémoire - -print("\n web_srv_test3.lua zf190127.0141 \n") - -sck_tmr1 = tmr.create() - -srv = net.createServer(net.TCP) -srv:listen(80, function(conn) - conn:on("receive", function(client, request) - print(request) - client:send("

ESP8266
Server is working!

"..tmr.now().."\n\n") - - - end) - conn:on("sent", function(c) c:close() end) -end)