Mon serveur HTML fonctionne bien maintenant, mais pas encore le serveur ASP !

This commit is contained in:
Christian Zufferey
2019-01-26 18:42:13 +01:00
parent fb00c5ed6d
commit 604267dbff
4 changed files with 22 additions and 22 deletions

View File

@@ -7,16 +7,13 @@
</head>
<body>
<h1>ESP8266 home page 190126.1757</h1>
<br>___________________<br><br>
<h2>Différentes pages HTML:<br></h2>
<h1>ESP8266 home page 190126.1836</h1>
<h2>Différentes pages HTML:</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>

View File

@@ -7,10 +7,10 @@
</head>
<body>
<h1>ESP8266 page 1 190126.1757</h1>
<h1>ESP8266 page 1 190126.1841</h1>
<br>
Coucou c'est la page 1 !<br>
<a href="index.html">Retour à la home page...</a><br>
<a href="/">Retour à la home page...</a><br>
</body>

View File

@@ -7,10 +7,10 @@
</head>
<body>
<h1>ESP8266 page 2 190126.1757</h1>
<h1>ESP8266 page 2 190126.1840</h1>
<br>
Coucou c'est la page 2 !<br>
<a href="index.html">Retour à la home page...</a><br>
<a href="/">Retour à la home page...</a><br>
</body>

View File

@@ -1,20 +1,24 @@
-- petit script de serveur WEB avec Active Server Page Zyx
-- petit script de serveur WEB avec Active Server Page ZYX
print("\n web_srv2.lua zf190126.1658 \n")
print("\n web_srv2.lua zf190126.1837 \n")
-- 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
function send_file(zclient, zfilename)
if zfilename == "" then zfilename = "index.html" end
if file.open(zfilename, "r") then
repeat
local line=file.read('\n')
if line then
zclient:send(line)
end
until not line
file.close()
else
zclient:send("<html><h1>"..zfilename.." not found - 404 error.</h1><a href='index.html'>Home</a><br></html>")
end
end
srv = net.createServer(net.TCP)
srv:listen(80, function(conn)
conn:on("receive", function(client, request)
@@ -40,7 +44,6 @@ 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")