diff --git a/http/args.lua b/http/args.lua
index e359f90..51e3463 100644
--- a/http/args.lua
+++ b/http/args.lua
@@ -1,5 +1,5 @@
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")
+ connection:send("HTTP/1.0 200 OK\r\nContent-Type: text/html\r\nCache-Control: private, no-store\r\n\r\n")
connection:send('
Arguments')
connection:send('')
connection:send('Arguments
')
diff --git a/http/file_list.lua b/http/file_list.lua
index 8f334e3..55c1389 100644
--- a/http/file_list.lua
+++ b/http/file_list.lua
@@ -1,5 +1,5 @@
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")
+ connection:send("HTTP/1.0 200 OK\r\nContent-Type: text/html\r\nCache-Control: private, no-store\r\n\r\n")
connection:send('Server File Listing')
connection:send('')
connection:send('Server File Listing
')
diff --git a/http/garage_door_opener.lua b/http/garage_door_opener.lua
index baca7d3..65b34e4 100644
--- a/http/garage_door_opener.lua
+++ b/http/garage_door_opener.lua
@@ -16,7 +16,7 @@ local function pushTheButton(connection, pin)
gpio.mode(pin, gpio.INPUT)
-- Send back JSON response.
- connection:send("HTTP/1.0 200 OK\r\nContent-Type: application/json\r\Cache-Control: private, no-store\r\n\r\n")
+ connection:send("HTTP/1.0 200 OK\r\nContent-Type: application/json\r\nCache-Control: private, no-store\r\n\r\n")
connection:send('{"error":0, "message":"OK"}')
end
@@ -26,7 +26,7 @@ return function (connection, args)
if args.door == "1" then pushTheButton(connection, 3) -- GPIO0
elseif args.door == "2" then pushTheButton(connection, 4) -- GPIO2
else
- connection:send("HTTP/1.0 400 OK\r\nContent-Type: application/json\r\Cache-Control: private, no-store\r\n\r\n")
+ connection:send("HTTP/1.0 400 OK\r\nContent-Type: application/json\r\nCache-Control: private, no-store\r\n\r\n")
connection:send('{"error":-1, "message":"Bad door"}')
end
end
diff --git a/http/node_info.lua b/http/node_info.lua
index 5d19055..ccb5bad 100644
--- a/http/node_info.lua
+++ b/http/node_info.lua
@@ -1,29 +1,29 @@
-local function sendHeader(connection)
- 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 sendAttr(connection, attr, val)
- connection:send("".. attr .. ": " .. val .. "
\n")
-end
-
-return function (connection, args)
- collectgarbage()
- sendHeader(connection)
- connection:send('A Lua script sample')
- connection:send('')
- connection:send('Node info
')
- majorVer, minorVer, devVer, chipid, flashid, flashsize, flashmode, flashspeed = 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, '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
+local function sendHeader(connection)
+ connection:send("HTTP/1.0 200 OK\r\nContent-Type: text/html\r\nCache-Control: private, no-store\r\n\r\n")
+end
+
+local function sendAttr(connection, attr, val)
+ connection:send("".. attr .. ": " .. val .. "
\n")
+end
+
+return function (connection, args)
+ collectgarbage()
+ sendHeader(connection)
+ connection:send('A Lua script sample')
+ connection:send('')
+ connection:send('Node info
')
+ majorVer, minorVer, devVer, chipid, flashid, flashsize, flashmode, flashspeed = 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, '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
diff --git a/http/updateaplist.lua b/http/updateaplist.lua
deleted file mode 100644
index 9ed369c..0000000
--- a/http/updateaplist.lua
+++ /dev/null
@@ -1,14 +0,0 @@
-local function storelist(t)
--- connection:send(cjson.encode(t))
--- print(cjson.encode(t))
- file.remove("http/aplist.json")
- file.open("http/aplist.json","w+")
- file.writeline(cjson.encode(t))
- file.close()
-end
-
-return function(connection,args)
- wifi.sta.getap(storelist)
- connection:send("HTTP/1.0 200 OK\r\nContent-Type: application/json\r\nCache-Control: private, no-store\r\n\r\n")
- connection:send('{"error":0, "message":"OK"}')
-end
diff --git a/init.lua b/init.lua
index ce73c1f..0080b80 100644
--- a/init.lua
+++ b/init.lua
@@ -25,7 +25,7 @@ local compileAndRemoveIfNeeded = function(f)
end
end
-local serverFiles = {'httpserver.lua', 'httpserver-request.lua', 'httpserver-static.lua', 'httpserver-error.lua'}
+local serverFiles = {'httpserver.lua', 'httpserver-request.lua', 'httpserver-static.lua', 'httpserver-error.lua','http/ual.lua'}
for i, f in ipairs(serverFiles) do compileAndRemoveIfNeeded(f) end
compileAndRemoveIfNeeded = nil