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