Post your best Lua script examples here

User avatar
By kbaykar
#41851 Hi All,

During my experience with ESP8266 WiFi Module to setup a web server, I hit the problem that every request from browser ends up in two requests; one is the request I actually made and the other one is something to do with modern browsers looking for an icon to show in the web address bar.

Quick googling on "favicon.ico" told me that browsers automatically generates “GET /favicon.ico” request with user's every actual request. There is almost no way to stop browsers' “GET /favicon.ico” request unless providing a proper "favicon.ico" file to satisfy their request.

So, I did some coding to send my "favicon.ico" to browser when I get such “GET /favicon.ico” request, as seen below:

Image

Sample code can be found on the link below:

http://blog.toganteknoloji.com.tr/

For further queries email me kemalbaykar@gmail.com.

Regards.
User avatar
By Travis
#42085 Good tip!

I embedded mine as a tiny PNG inline like this:

Code: Select all<link rel='icon' href='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAS0lEQVR42s2SMQ4AIAjE+P+ncSYdasgNXMJgcyIIlVKPIKdvioAXyWBeJmVpqRZKWtj9QWAKZyWll50b8IcL9JUeQF50n28ckyb0ADG8RLwp05YBAAAAAElFTkSuQmCC' type='image/x-png' />


But it still gets requested for other files, so it's not optimal.
Attachments
esp8266-favicon.PNG
esp8266 favicon
esp8266-favicon.PNG (1.11 KiB) Viewed 18740 times
User avatar
By Simple Simon
#42800 Hi. Maybe a truly "proper" solution is simply to have an actual web server.

I couldn't find one, so I wrote one. It's what I term "alpha" level,
which for most of the open-source world is probably considered "production quality" :D
Runs in 14K of heap, and the compiled code is less than that.
Supports dynamic pages (GPIO controller sample included).

Of course, it serves up favicon.ico just the same as any other requested file.

https://github.com/SimpleSimonsSolution ... UWebServer