diff --git a/http/file_list.lua b/http/file_list.lua
index ddc3edf..e8bc675 100644
--- a/http/file_list.lua
+++ b/http/file_list.lua
@@ -1,21 +1,20 @@
-local function sendHeader(connection)
+return function (connection, args)
connection:send("HTTP/1.0 200 OK\r\nContent-Type: text/html\r\Cache-Control: private, no-store\r\n\r\n")
-end
-
-local function sendFileList(connection)
+ connection:send('
Server File Listing')
+ connection:send('')
+ connection:send('Server File Listing
')
connection:send("\n")
+
local l = file.list()
for name, size in pairs(l) do
- connection:send(" - " .. name .. " (" .. size .. ")
\n")
+
+ local isHttpFile = string.match(name, "(http/)") ~= nil
+ local url = string.match(name, ".*/(.*)")
+ if isHttpFile then
+ connection:send(' - ' .. url .. " (" .. size .. " bytes)
\n")
+ end
+
end
connection:send("
\n")
-end
-
-return function (connection, args)
- sendHeader(connection)
- connection:send('A Lua script sample')
- connection:send('')
- connection:send('File Listing
')
- sendFileList(connection)
connection:send('')
end
diff --git a/http/index.html b/http/index.html
index 4383ee4..887bd6a 100644
--- a/http/index.html
+++ b/http/index.html
@@ -8,20 +8,21 @@
Hello World!
- nodemcu-httpserver
- This page is served by nodemcu-httpserver running on an ESP8266. One of the smallest web servers... ever!
+
+ This page is served by nodemcu-httpserver running on an ESP8266 that uses the NodeMCU firmware.
+ NodeMCU puts a Lua interpreter inside the ESP8266. This is surely one of the smallest web servers to date!
+
Where's the source code?
- Right here
+ You can find the Lua code for nodemcu-httpserver in GitHub
- Show me the demos
+ Serve me some pages!
diff --git a/http/node_info.lua b/http/node_info.lua
index a563692..5d19055 100644
--- a/http/node_info.lua
+++ b/http/node_info.lua
@@ -13,15 +13,17 @@ return function (connection, args)
connection:send('')
connection:send('Node info
')
majorVer, minorVer, devVer, chipid, flashid, flashsize, flashmode, flashspeed = node.info();
- connection:send('Node info:')
- sendAttr(connection, "majorVer" , majorVer)
- sendAttr(connection, "devVer" , devVer)
- sendAttr(connection, "chipid" , chipid)
- sendAttr(connection, "flashid" , flashid)
- sendAttr(connection, "flashsize" , flashsize)
- sendAttr(connection, "flashmode" , flashmode)
- sendAttr(connection, "flashspeed" , flashspeed)
- sendAttr(connection, "node.heap()" , node.heap())
+ sendAttr(connection, "majorVer" , majorVer)
+ sendAttr(connection, "devVer" , devVer)
+ sendAttr(connection, "chipid" , chipid)
+ sendAttr(connection, "flashid" , flashid)
+ sendAttr(connection, "flashsize" , flashsize)
+ sendAttr(connection, "flashmode" , flashmode)
+ sendAttr(connection, "flashspeed" , flashspeed)
+ sendAttr(connection, "node.heap()" , node.heap())
+ sendAttr(connection, 'Memory in use (KB)' , collectgarbage("count"))
+ sendAttr(connection, 'IP address' , wifi.sta.getip())
+ sendAttr(connection, 'MAC address' , wifi.sta.getmac())
connection:send('
')
connection:send('