From 316af66d3c1bd1b7a5ddfb0e819cc35e9b8a005b Mon Sep 17 00:00:00 2001 From: Marcos Kirsch Date: Sun, 22 Feb 2015 16:06:06 -0600 Subject: [PATCH] Improve demo files --- http/file_list.lua | 25 ++++++++++++------------- http/index.html | 21 +++++++++++---------- http/node_info.lua | 20 +++++++++++--------- 3 files changed, 34 insertions(+), 32 deletions(-) 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") -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('') end