/* Some random cgi routines. Used in the LED example and the page that returns the entire flash as a binary. Also handles the hit counter on the main page. */ /* * ---------------------------------------------------------------------------- * "THE BEER-WARE LICENSE" (Revision 42): * Jeroen Domburg wrote this file. As long as you retain * this notice you can do whatever you want with this stuff. If we meet some day, * and you think this stuff is worth it, you can buy me a beer in return. * ---------------------------------------------------------------------------- */ #include #include "cgi.h" static long hitCounter=0; //Template code for the counter on the index page. int ICACHE_FLASH_ATTR tplCounter(HttpdConnData *connData, char *token, void **arg) { char buff[128]; if (token==NULL) return HTTPD_CGI_DONE; if (os_strcmp(token, "counter")==0) { hitCounter++; os_sprintf(buff, "%ld", hitCounter); } httpdSend(connData, buff, -1); return HTTPD_CGI_DONE; }