File tree 2 files changed +12
-4
lines changed
libraries/ESP8266WebServer
2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change 6
6
const char * ssid = " ........" ;
7
7
const char * password = " ........" ;
8
8
MDNSResponder mdns;
9
-
10
9
ESP8266WebServer server (80 );
11
10
11
+ const int led = 13 ;
12
+
12
13
void handle_root () {
14
+ digitalWrite (led, 1 );
13
15
server.send (200 , " text/plain" , " hello from esp8266!" );
16
+ digitalWrite (led, 0 );
14
17
}
15
18
16
19
bool handle_not_found (){
20
+ digitalWrite (led, 1 );
17
21
String message = " URI: " ;
18
22
message += server.uri ();
19
23
message += " \n Method: " ;
@@ -26,11 +30,14 @@ bool handle_not_found(){
26
30
}
27
31
message += " \n NotFound!" ;
28
32
server.send (404 , " text/plain" , message);
33
+ digitalWrite (led, 0 );
29
34
return true ;
30
35
}
31
36
32
37
void setup (void ){
33
38
Serial.begin (115200 );
39
+ pinMode (led, OUTPUT);
40
+ digitalWrite (led, 0 );
34
41
WiFi.begin (ssid, password);
35
42
Serial.println (" " );
36
43
Original file line number Diff line number Diff line change @@ -42,15 +42,16 @@ class ESP8266WebServer
42
42
typedef std::function<bool (void )> TNotFoundHandlerFunction;
43
43
void on (const char * uri, THandlerFunction handler);
44
44
void on (const char * uri, HTTPMethod method, THandlerFunction fn);
45
- void onNotFound (TNotFoundHandlerFunction fn);// called when handler is not assigned
45
+ // called when handler is not assigned, return true if you handle it else return false to let the class return 404
46
+ void onNotFound (TNotFoundHandlerFunction fn);
46
47
47
48
String uri () { return _currentUri; }
48
49
HTTPMethod method () { return _currentMethod; }
49
50
WiFiClient client () { return _currentClient; }
50
51
51
52
String arg (const char * name);// get request argument value
52
- String arg (int i);// get request argument value buy number
53
- String argName (int i);// get request argument name buy number
53
+ String arg (int i);// get request argument value by number
54
+ String argName (int i);// get request argument name by number
54
55
int args ();// get arguments count
55
56
bool hasArg (const char * name);// check if argument exists
56
57
You can’t perform that action at this time.
0 commit comments