File tree Expand file tree Collapse file tree 3 files changed +22
-2
lines changed Expand file tree Collapse file tree 3 files changed +22
-2
lines changed Original file line number Diff line number Diff line change 5
5
GPIO_NUM = 2 # Builtin led (D4)
6
6
7
7
# Wi-Fi configuration
8
- STA_SSID = "MEE_MI "
9
- STA_PSK = "PinkFloyd1969 "
8
+ STA_SSID = "FlagTest "
9
+ STA_PSK = "0233110330 "
10
10
11
11
# Disable AP interface
12
12
ap_if = network .WLAN (network .AP_IF )
32
32
33
33
# Handler for path "/cmd?led=[on|off]"
34
34
def handleCmd (socket , args ):
35
+ global ledData
35
36
if 'led' in args :
36
37
if args ['led' ] == 'on' :
38
+ ledData ["status" ]= "ON"
37
39
pin .off ()
38
40
elif args ['led' ] == 'off' :
41
+ ledData ["status" ]= "OFF"
39
42
pin .on ()
40
43
ESP8266WebServer .ok (socket , "200" , args ["led" ])
41
44
else :
@@ -46,6 +49,12 @@ def handleCmd(socket, args):
46
49
47
50
# Register handler for each path
48
51
ESP8266WebServer .onPath ("/cmd" , handleCmd )
52
+ ESP8266WebServer .setDocPath ("/www2" )
53
+
54
+ ledData = {
55
+ "status" :"Off" ,
56
+ }
57
+ ESP8266WebServer .setTplData (ledData )
49
58
50
59
try :
51
60
while True :
Original file line number Diff line number Diff line change
1
+ < html >
2
+ < body >
3
+ < h1 > This is index.html</ h1 >
4
+ </ body >
5
+ < html >
6
+
Original file line number Diff line number Diff line change
1
+ < html >
2
+ < body >
3
+ < h1 > Status:{status}</ h1 >
4
+ </ body >
5
+ </ html >
You can’t perform that action at this time.
0 commit comments