This commit is contained in:
Christian Zufferey
2019-01-26 17:59:43 +01:00
parent dc95448d17
commit 9528fae38c
11 changed files with 124 additions and 67 deletions

50
Robot_Lua/index_robot.html Executable file
View File

@@ -0,0 +1,50 @@
<!DOCTYPE html>
<html>
<body>
<meta charset='utf-8' name='viewport' content='width=device-width, initial-scale=1.0'>\n"
<html>
<head>
<title>ESP8266 home page</title>
</head>
<style>
a:link {
color: #ff0000;
background-color: transparent;
text-decoration: none
}
a:visited {
color: #ff0000;
background-color: transparent;
text-decoration: none
}
a:hover {
color: #ff0000;
background-color: transparent;
text-decoration: underline
}
a:active {
color: #ff0000;
background-color: transparent;
text-decoration: none
}
</style>
<Body style="background-color:lightgrey">
<p style="color:darkblue"><B>ESP8266 server </p></B><BR>
___________________<BR><BR>
<h2>Employee Information:<br></h2>
<h3>
<a href="bob.htm">Bob</a><BR>
<a href="jill.htm">Jill</a><BR>
<a href="barb.htm">Barb</a><BR>
</h3>
<BR>___________________<BR>
</body>
</html>

22
zyx-framework/index.html Normal file
View File

@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html lang="fr" dir="ltr">
<head>
<meta charset='utf-8' name='viewport' content='width=device-width, initial-scale=1.0'>
<title>ESP8266 home page</title>
</head>
<body>
<h1>ESP8266 home page 190126.1757</h1>
<br>___________________<br><br>
<h2>Différentes pages HTML:<br></h2>
<h3>
<a href="page1.html">Page 1</a><br>
<a href="page2.html">Page 2</a><br>
<a href="page_qui_existe_pag.html">Page qui n'existe pas !</a><br>
</h3>
<br>___________________<br>
</body>
</html>

17
zyx-framework/page1.html Normal file
View File

@@ -0,0 +1,17 @@
<!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 1</title>
</head>
<body>
<h1>ESP8266 page 1 190126.1757</h1>
<br>
Coucou c'est la page 1 !<br>
<a href="index.html">Retour à la home page...</a><br>
</body>
</html>

17
zyx-framework/page2.html Normal file
View File

@@ -0,0 +1,17 @@
<!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.1757</h1>
<br>
Coucou c'est la page 2 !<br>
<a href="index.html">Retour à la home page...</a><br>
</body>
</html>

View File

@@ -1,14 +0,0 @@
<!DOCTYPE html>
<html>
<body>
<t1>Mesures de température 190123.2000</t1>
<%
for i=1,5 do
zoutput("la valeur est "..i.."<br>")
end
%>
</body>
</html>

View File

@@ -1,9 +0,0 @@
srv=net.createServer(net.TCP)
srv:listen(80,function(conn)
conn:on("receive",function(conn,payload)
print(payload)
conn:send("<h1> ESP8266<BR>Server is working!</h1>")
conn:close()
end)
end)

View File

@@ -1,38 +0,0 @@
-- petit script de serveur WEB Wifi
print("\n web_srv.lua zf190119.1932 \n")
--dofile("web_get.lua")
dofile("web_html.lua")
srv = net.createServer(net.TCP)
srv:listen(80, function(conn)
conn:on("receive", function(client, request)
_, _, method, path, vars = string.find(request, "([A-Z]+) (.+)?(.+) HTTP")
--print("\n\nweb_srv")
--print("method: ",method)
--print("path: ",path)
--print("request: ",request)
--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
-- web_get()
html_home()
client:send(buf)
buf=nil
end
end)
conn:on("sent", function(c) c:close() end)
end)

View File

@@ -1,9 +1,19 @@
-- petit script de serveur WEB Wifi
-- petit script de serveur WEB avec Active Server Page Zyx
print("\n web_srv.lua zf181018.1610 \n")
print("\n web_srv2.lua zf190126.1658 \n")
--dofile("web_get.lua")
--dofile("web_html.lua")
-- send a file from memory to the client; max. line length = 1024 bytes!
function send_file(client, filename)
if file.open(filename, "r") then
repeat
local line=file.read('\n')
if line then
client:send(line)
end
until not line
file.close()
end
end
srv = net.createServer(net.TCP)
srv:listen(80, function(conn)
@@ -30,12 +40,14 @@ srv:listen(80, function(conn)
end
file_html=string.gsub(path, "/", "")
print("file_html: ",file_html)
send_file(conn, file_html)
conn:send("<h1> ESP8266<BR>Server is working!</h1>\n\n")
-- conn:send("<h1> ESP8266<BR>Server is working!</h1>\n\n")
end
end)
conn:on("sent", function(c) c:close() end)
end)