Post your best Lua script examples here

User avatar
By alonewolfx2
#3902 thank you for sharing. I did some test. firstly it's working with lua request like this :D
Code: Select all<?lua print("Free Ram: "..node.heap().."<br>") print("Chip Id: "..node.chipid()) ?>
or
Code: Select all<?lua if (gpio.read(0) == 1) then print("high"); else print("low"); end ?><br>
   <?lua if (gpio.read(1) == 1) then print("high"); else print("low"); end ?>

but post request not working. and its crashing when wrong file request like " test.html". we need some change.
User avatar
By gerardwr
#3904
alonewolfx2 wrote:thank you for sharing. I did some test. firstly it's working with lua request like this :D
Code: Select all<?lua print("Free Ram: "..node.heap().."<br>") print("Chip Id: "..node.chipid()) ?>
or
Code: Select all<?lua if (gpio.read(0) == 1) then print("high"); else print("low"); end ?><br>
   <?lua if (gpio.read(1) == 1) then print("high"); else print("low"); end ?>

but post request not working. and its crashing when wrong file request like " test.html". we need some change.


That's excellent news!

Will test later today. If this works as expected I will stop development on my own webserver, and continue with the migrated elua code.

How about you?
User avatar
By alonewolfx2
#3906
gerardwr wrote:
alonewolfx2 wrote:thank you for sharing. I did some test. firstly it's working with lua request like this :D
Code: Select all<?lua print("Free Ram: "..node.heap().."<br>") print("Chip Id: "..node.chipid()) ?>
or
Code: Select all<?lua if (gpio.read(0) == 1) then print("high"); else print("low"); end ?><br>
   <?lua if (gpio.read(1) == 1) then print("high"); else print("low"); end ?>

but post request not working. and its crashing when wrong file request like " test.html". we need some change.


That's excellent news!

Will test later today. If this works as expected I will stop development on my own webserver, and continue with the migrated elua code.

How about you?


Agree. My favorite part of the elua webserver is just filename sending to the uart.and can be turned off.
Code: Select all.v,...ZbRS JzD@JStbgz
NodeMcu 0.9.2 build 20141202  powered by Lua 5.1.4
> index.html
index.pht

i think we could continue from elua. Here is to do list
1- Get or Post request handling
2- Adding some security
..
User avatar
By alonewolfx2
#3910 Some more test.
Code: Select all--startup heap and after every request
> @xSG.1.~.LC.   Jzbgf.hbcz
NodeMcu 0.9.2 build 20141202  powered by Lua 5.1.4
> print(node.heap())
9720
> index.pht
print(node.heap())
8912
> index.pht
print(node.heap())
8864
> index.pht
index.pht
print(node.heap())
8720
> index.pht
print(node.heap())
9256
>
--- after a couple file not found
> index.tpl
index.tpl
print(node.heap())
8680
> index.tpl
print(node.heap())
7464
> index.tpl
index.tpl
index.tpl
print(node.heap())
7408
> print(node.heap())
7840
> print(node.heap())
8592
>


it seems heap recovering to fast. and i tried pc with android same time,same page request. but it seems not working with multiple request.