Post your best Lua script examples here

User avatar
By JeremiahLandi
#34016 Great post!

Is there an easy way to change the buttons to a HTML range input?

Links or aid would be appreciated.

Edit: Figured it out. For anyone curious here is the code with some modes. I put everything in a table to make it display nicely.

Code: Select allconn:send('<table style="wide:100%">\n')
   conn:send('<tr>')
    conn:send('<td><input type="submit" name="pwmi" value="OFF"></td>\n')
   conn:send('<td><input type="range" name="dimmer" min="0" max="100"></td>\n')
   conn:send('<td><input type="submit"></td>\n')
    conn:send('<td><input type="submit" name="pwmi" value="ON"></td>\n')
   conn:send('</tr>')
   conn:send('</table>')
Last edited by JeremiahLandi on Sat Nov 14, 2015 9:51 pm, edited 1 time in total.
User avatar
By JeremiahLandi
#34018
GregorZagar wrote:HI.
What is HTTP url of commands used in this lua script for butons?

I'm trying to power ON/OFF leds with bookmarked shortcut in chrome browser.

tryed http://ip.of.my.wsp/pwmi=OFF and esp chrashed.

Any suggestions?


@GregorZagar

This is done with POST requests and not GET requests.

GET == Default. Appends the form-data to the URL in name/value pairs: URL?name=value&name=value
POST == Sends the form-data as an HTTP post transaction

http://www.w3schools.com/tags/att_form_method.asp

Just change the "POST" to "GET". Then you can edit away in the URL ;)

Code: Select allconn:send('<form action="" method="GET">\n')


Edit: Also include solution...
User avatar
By Rure
#36974 Hi, I'm new to the forum, the code works fine in the ESP, but I have a problem, I put led.gif in esp. I used the following code:
conn: send ('<IMG SRC = "/ led.gif" WIDTH = "150" height = "101" border = "1"> <br> <br> \ n')
well, I've tried everything and I can not view it in the Web page.
What would be the correct code. Thank you.
User avatar
By awball
#41427
JeremiahLandi wrote:
GregorZagar wrote:HI.
What is HTTP url of commands used in this lua script for butons?

I'm trying to power ON/OFF leds with bookmarked shortcut in chrome browser.

tryed http://ip.of.my.wsp/pwmi=OFF and esp chrashed.

Any suggestions?


@GregorZagar

This is done with POST requests and not GET requests.

GET == Default. Appends the form-data to the URL in name/value pairs: URL?name=value&name=value
POST == Sends the form-data as an HTTP post transaction

http://www.w3schools.com/tags/att_form_method.asp

Just change the "POST" to "GET". Then you can edit away in the URL ;)

Code: Select allconn:send('<form action="" method="GET">\n')


Edit: Also include solution...

I tried the "get" option which did generate a 192.168.0.53/?pwmi=80 in the URL however it did not turn on the LED the URL or through the buttons. Changing back to post allowed the buttons to work, but URL did not. through

Are you using the code from this post viewtopic.php?p=6081#p6081 ?