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

28
WEB/web_html_multi/bob.htm Executable file
View File

@@ -0,0 +1,28 @@
<html>
<head>
<title>ESP8266 Bob information 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:FAEBD7">
<p style="color:darkblue"><B>ESP8266 server </p></B>
<a href="index.htm">Home</a><BR>
___________________<BR><BR>
<h2>Employee Information:<br></h2>
<BR>
<B>Bob Brown</B><BR>
1234 Onix Dr.<BR>
Barstow, Ca 52266<BR>
905-333-3333 ext 125<BR>
<BR>
Bob@someemail.com<BR>
<BR>
Currently out of office.
<BR>___________________<BR>
</body>
</html>

22
WEB/web_html_multi/index.htm Executable file
View File

@@ -0,0 +1,22 @@
<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>

View File

@@ -0,0 +1,23 @@
print("tutu")
srv=net.createServer(net.TCP)
srv:listen(80,function(conn)
conn:on("receive", function(client,payload)
tgtfile = string.sub(payload,string.find(payload,"GET /")
+5,string.find(payload,"HTTP/")-2)
print(payload)
if tgtfile == "" then tgtfile = "index.htm" end
local f = file.open(tgtfile,"r")
if f ~= nil then
client:send(file.read())
file.close()
else
client:send("<html>"..tgtfile.." not found - 404 error.<BR><a href='index.htm'>Home</a><BR>")
end
-- client:close();
-- collectgarbage();
conn:on("sent", function(c) c:close() end)
f = nil
tgtfile = nil
end)
end)