Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By mianos
#39028 I'd put the templates in the ROM, read the bytes word at a time and write a simple finite state machine based templater, something like jinja or handlebars. For my esp micropython port I encode the text into blocks of 4 bytes and read them as words, shifting them into bytes. I'm just writing a web server for my micropython so I might actually write this before you do.
User avatar
By Top-Dog
#39134
I haven't looked at esphttpd, I'm not even sure what you mean, but if you're talking about passing arguments to an URL and having the function do something with those arguments then that's perfectly doable with just the ESP8266WebServer.


Do you have an example code snippet to show this functionality?
User avatar
By WereCatf
#39135
Top-Dog wrote:Do you have an example code snippet to show this functionality?


This is not a full sketch, but should be enough to illustrate the point:

Code: Select allvoid TogglePin() {
  if (server.method() == HTTP_GET) {
    for ( uint8_t i = 0; i < server.args(); i++ ) {
      if (server.argName(i) == "gpio") {
        int pin = atoi(server.arg(i).c_str());
        pinMode ( pin, OUTPUT );
        digitalWrite(pin, !digitalRead(pin));
      }
    }
    server.send ( 200, "text/plain", "OK.");
  }
}

setup()
{
//Do whatever, set WiFi, server and such up
  server.on ( "/togglepin", TogglePin );
}


You request the URL http://your.esp/togglepin?gpio=gpio_pin_number_here, like e.g. http://your.esp/togglepin?gpio=4 would toggle GPIO4. You can even toggle multiple pins in one URL with that code-snippet, if you like, as can be seen from the for - loop.