diff --git a/nodemcu/http/apple-touch-icon.png b/nodemcu/http/apple-touch-icon.png
new file mode 100644
index 0000000..de91784
Binary files /dev/null and b/nodemcu/http/apple-touch-icon.png differ
diff --git a/nodemcu/http/args.lua b/nodemcu/http/args.lua
new file mode 100644
index 0000000..f7a2790
--- /dev/null
+++ b/nodemcu/http/args.lua
@@ -0,0 +1,26 @@
+return function (connection, req, args)
+ 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 ')
+
+ local form = [===[
+
+ ]===]
+
+ connection:send(form)
+
+ connection:send('Received the following values: ')
+ connection:send("\n")
+ for name, value in pairs(args) do
+ connection:send('' .. name .. ': ' .. tostring(value) .. " \n")
+ end
+
+ connection:send(" \n")
+ connection:send('')
+end
diff --git a/nodemcu/http/file_list.lua b/nodemcu/http/file_list.lua
new file mode 100644
index 0000000..9e92a23
--- /dev/null
+++ b/nodemcu/http/file_list.lua
@@ -0,0 +1,30 @@
+return function (connection, req, args)
+ 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('')
+ coroutine.yield()
+ connection:send('Server File Listing ')
+
+ local remaining, used, total=file.fsinfo()
+ connection:send("Total size: " .. total .. " bytes \n")
+ connection:send("In Use: " .. used .. " bytes \n")
+ connection:send("Free: " .. remaining .. " bytes \n")
+
+ connection:send("\n")
+ connection:send("Files: \n")
+ connection:send("
\n")
+
+ for name, size in pairs(file.list()) do
+
+ local isHttpFile = string.match(name, "(http/)") ~= nil
+ if isHttpFile then
+ local url = string.match(name, ".*/(.*)")
+ connection:send(' ' .. url .. " (" .. size .. " bytes) \n")
+ -- this list could be very long, so we'll yield in order to avoid overflowing the send buffer.
+ coroutine.yield()
+ end
+ end
+ connection:send(" \n")
+ connection:send("\n")
+ connection:send('')
+end
diff --git a/nodemcu/http/garage_door_opener.css b/nodemcu/http/garage_door_opener.css
new file mode 100644
index 0000000..bcaa154
--- /dev/null
+++ b/nodemcu/http/garage_door_opener.css
@@ -0,0 +1,134 @@
+html, body {
+ height:100%;
+ margin: 0;
+ overflow: hidden;
+}
+
+body {
+
+ text-align: center;
+ background-color: black;
+ min-height: 100%;
+ color: black;
+}
+
+
+#remote {
+ background-color: #666;
+ width: 90%;
+ border-radius: 30px;
+ margin: 5% 5% 0;
+ height: 90%;
+ padding: 0;
+}
+
+#spacer {
+ clear: both;
+ border-top: 1px solid rgba(0, 0, 0, 0.5);
+ -moz-box-shadow: 1px 1px 1px;
+ box-shadow: 1px 1px 1px;
+ margin-right: 30px;
+ margin-left: 30px;
+}
+
+
+.button {
+ display: inline-block;
+ width: 43%;
+ margin: 20px 0 30px;
+ padding: 40px 0;
+ border-style: none;
+ color: rgba(192, 192, 192, 0.5);
+ text-decoration: none;
+ border-radius: 20px;
+ text-shadow: 0 0 1px rgba(0, 0, 0, 0.5);
+ font-size: 130px;
+ font-weight: bold;
+ background-color: #CCC;
+ -moz-box-shadow: 0 10px rgba(0, 0, 0, 0.25);
+ box-shadow: 0 10px rgba(0, 0, 0, 0.25);
+ position: relative;
+}
+
+
+.button-1 {
+ float: left;
+ margin-left: 5%;
+}
+
+.button-2 {
+ float: right;
+ margin-right: 5%;
+}
+
+
+
+.button span {
+
+
+}
+
+
+
+.button:hover span {
+
+
+}
+
+
+.button:active, .button:focus {
+
+
+}
+
+
+
+.button:active span {
+
+
+}
+
+
+#label {
+ font-family: "Lucida Grande", Lucida, Verdana, sans-serif;
+ background-color: rgba(0, 0, 0, 0.1);
+ width: 12px;
+ height: 12px;
+ display: block;
+ margin: 20px auto;
+ -webkit-border-radius: 20px;
+ -moz-border-radius: 20px;
+ border-radius: 20px;
+ text-indent: -99999px;
+ top: 20px;
+ position: relative;
+}
+
+#label.start {
+
+}
+
+#label.initalizing {
+
+}
+
+#label.connection {
+ background-color: orange;
+}
+
+#label.received {
+ background-color: orange;
+}
+
+#label.processing {
+ background-color: orange;
+}
+
+#label.ok {
+ background-color: green;
+}
+
+#label.bad {
+ background-color: red;
+}
+
diff --git a/nodemcu/http/garage_door_opener.html b/nodemcu/http/garage_door_opener.html
new file mode 100644
index 0000000..cc67ca2
--- /dev/null
+++ b/nodemcu/http/garage_door_opener.html
@@ -0,0 +1,84 @@
+
+
+
+
+
+
+ Garage Remote
+
+
+
+
+
+
+
diff --git a/nodemcu/http/garage_door_opener.lua b/nodemcu/http/garage_door_opener.lua
new file mode 100644
index 0000000..ca67617
--- /dev/null
+++ b/nodemcu/http/garage_door_opener.lua
@@ -0,0 +1,32 @@
+-- garage_door_opener.lua
+-- Part of nodemcu-httpserver, example.
+-- Author: Marcos Kirsch
+
+local function pushTheButton(connection, pin)
+
+ -- push the button!
+ -- Note that the relays connected to the garage door opener are wired
+ -- to close when the GPIO pin is low. This way they don't activate when
+ -- the chip is reset and the GPIO pins are in input mode.
+ gpio.write(pin, gpio.LOW)
+ gpio.mode(pin, gpio.OUTPUT)
+ gpio.write(pin, gpio.LOW)
+ tmr.delay(300000) -- in microseconds
+ gpio.write(pin, gpio.HIGH)
+ gpio.mode(pin, gpio.INPUT)
+
+ -- Send back JSON response.
+ 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
+
+return function (connection, req, args)
+ print('Garage door button was pressed!', args.door)
+ if args.door == "1" then pushTheButton(connection, 1) -- GPIO1
+ elseif args.door == "2" then pushTheButton(connection, 2) -- GPIO2
+ else
+ 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/nodemcu/http/index.html b/nodemcu/http/index.html
index 321de45..0db6ace 100644
--- a/nodemcu/http/index.html
+++ b/nodemcu/http/index.html
@@ -22,12 +22,11 @@
Index : This page (static)
Zipped : A compressed file (static)
Arguments : Parses arguments passed in the URL and prints them. (Lua)
- Post : A form that uses POST method, should error. (static)
+ Post : A form that uses POST method. Displays different content based on HTTP method. (Lua)
Garage door opener : Control GPIO lines via the server. (Lua)
NodeMCU info : Shows some basic NodeMCU(Lua)
List all server files : Displays a list of all the server files. (Lua)
Foo : A file that doesn't exist. Should error (404 error)
- DaBomb : A working POST example