mirror of https://github.com/jeelabs/esp-link.git
parent
649dc26851
commit
a01c02245f
@ -0,0 +1,13 @@ |
||||
<html><head><title>Test</title></head> |
||||
<body> |
||||
|
||||
<p> |
||||
There's a LED. You can't see it, so it's no use clicking any of the buttons below. The buttons |
||||
do, however, turn the LED on and off. |
||||
</p> |
||||
<form method="post" action="led.cgi"> |
||||
<input type="submit" name="led" value="1"> |
||||
<input type="submit" name="led" value="0"> |
||||
</form> |
||||
|
||||
</body></html> |
@ -0,0 +1,10 @@ |
||||
<html><head><title>Test</title></head> |
||||
<body> |
||||
|
||||
<form method="post" action="test.cgi"> |
||||
<input type="text" name="Test1" value="t1"> |
||||
<input type="text" name="Test2" value="t2"> |
||||
<input type="submit" name="DoIt" value="Do It"> |
||||
</form> |
||||
|
||||
</body></html> |
@ -0,0 +1,50 @@ |
||||
/*
|
||||
Some random cgi routines. |
||||
*/ |
||||
|
||||
#include <string.h> |
||||
#include <osapi.h> |
||||
#include "httpd.h" |
||||
#include "cgi.h" |
||||
#include "io.h" |
||||
|
||||
int ICACHE_FLASH_ATTR cgiLed(HttpdConnData *connData) { |
||||
int len; |
||||
char buff[1024]; |
||||
|
||||
if (connData->conn==NULL) { |
||||
//Connection aborted. Clean up.
|
||||
return HTTPD_CGI_DONE; |
||||
} |
||||
|
||||
len=httpdFindArg(connData->postBuff, "led", buff, sizeof(buff)); |
||||
ioLed(atoi(buff)); |
||||
|
||||
httpdRedirect(connData, "led.html"); |
||||
return HTTPD_CGI_DONE; |
||||
} |
||||
|
||||
int ICACHE_FLASH_ATTR cgiTest(HttpdConnData *connData) { |
||||
int len; |
||||
char val1[128]; |
||||
char val2[128]; |
||||
char buff[1024]; |
||||
|
||||
if (connData->conn==NULL) { |
||||
//Connection aborted. Clean up.
|
||||
return HTTPD_CGI_DONE; |
||||
} |
||||
|
||||
httpdStartResponse(connData, 200); |
||||
httpdHeader(connData, "Content-Type", "text/plain"); |
||||
httpdEndHeaders(connData); |
||||
|
||||
|
||||
httpdFindArg(connData->postBuff, "Test1", val1, sizeof(val1)); |
||||
httpdFindArg(connData->postBuff, "Test2", val2, sizeof(val2)); |
||||
len=os_sprintf(buff, "Field 1: %s\nField 2: %s\n", val1, val2); |
||||
espconn_sent(connData->conn, (uint8 *)buff, len); |
||||
|
||||
return HTTPD_CGI_DONE; |
||||
} |
||||
|
@ -0,0 +1,9 @@ |
||||
#ifndef CGI_H |
||||
#define CGI_H |
||||
|
||||
#include "httpd.h" |
||||
|
||||
int cgiLed(HttpdConnData *connData); |
||||
int cgiTest(HttpdConnData *connData); |
||||
|
||||
#endif |
Loading…
Reference in new issue