- Wed Jan 21, 2015 2:39 pm
#7887
I managed to create a Web-Server with a html-page serving an image using bradvoy's "Another web Server" found at
viewtopic.php?f=19&t=1099The html-page looks like this:
Code: Select all<html><head><title>Matchbox-Srvr</title></head><body>
<h1> <img src="box.jpg"> Welcome to the Matchbox!</h1><hr>
...
<hr></body></html>
To respond to the get-request to the homepage and the Image and i use this Elements in the pages-aray:
Code: Select all-- define pages:
pages = {}
pages["/box.jpg"] = function(request)
file.open("box1r.jpg")
X = file.read()
file.close()
tmr.wdclr()
return X , "image/jpg"
end
pages["/"] = function(request)
file.open("home.html")
X=file.read()
file.close()
tmr.wdclr()
X = X ..F()
return X
end So far the Pro's.
Not so fine:
Due to the Limitations of "Another web server" all pages must be smaller than 1.4Kb.
It's not really easy to find a picture flie that fits into this size.
Due to the limited Heap-resources nodeMCU will reboot if the Server-Project becomes too complex (=memory-consuming).
So it is possible to serve a page with a small image OR start some cgi-scripts doing some "beeps" or "pwms" OR GPIO-toggeling but if you combine only few of them into one Project, free Heap will drop under 3-4K and the Server reboots
So far nodeMCU and the Web-Server is great for a quick proof of concept, but due to the memory-restrictions i didn't manage to realize a "real world-Project" like a HTML-controlled moodlight with a standalone ESP8266 & nodeMCU.
(If someone knows how to get around the menory-restricitions, please let me know..)