Post your best Lua script examples here

User avatar
By StefanL38
#12087 I tried two scripts attached to posts here with zero success.
with init.lua I got only an errormessage
dofile("init.lua")
init.lua:1: unexpected symbol near 'ï'
But I even can't find the character 'ï' inside the file :-((

With the other lua-script I get the error-message
dofile("httpd.lua")
not enough memory

I guess I know much too less about how to setup a webserver.

Can anybody point me to a link which explains the basics and the tricks and traps
or can attach a script AND a description what to upload to where and how much memory
must be free to make a KISS test-webserver work?

best regards

Stefan
User avatar
By dpwhittaker
#12097 I am nearing completion on a new version based on my flash function technique. It is the first version which is looking to remain stable and not max out memory.

https://www.dropbox.com/sh/tk137znh9pkk ... tvl-a?dl=0

This is not complete... save hasn't been transferred to the new system yet (it should define onData rather than immediately processing). I also am going to make Get requests define flash functions as well. I'll also send headers to a flash function one by one instead of storing them.

Right now, I've got it down to 5k free at the lowest point of a pht file that is large enough to cause the coroutine to yield. My goal is to re-implement the Mini Web IDE and uMessenger in this framework before I call it complete, both as real-world tests and complete examples. uMessenger provides a particularly interesting example because it currently requires an arduino for the oled interface, and I plan to make it work completely on the esp. It will be a good example of interfacing with an external library that has its own memory needs. I'm not sure I have the free memory to support the webserver and oled right now, but I'll either get there, or show some techniques for letting the webserver finish and clean up before executing the oled code. I'll also write an extensive readme.md and post it to github. All this should be done in the next weekend or two.
User avatar
By alon24
#12166
Patriko wrote:Hi!

Maybe it'll be a good idea to convert it into C and embed into nodemcu firmware?

Cheers,
Patriko


This would be great since it will save up on one step of copying the files, compiling them and deleteing (flashmod and llbin).
Its a very good enhancement!!!