Skip to content

Commit 69b4a08

Browse files
committed
add simple demo program for doc path and template file
1 parent ec4fc50 commit 69b4a08

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

Simple_led.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
GPIO_NUM = 2 # Builtin led (D4)
66

77
# Wi-Fi configuration
8-
STA_SSID = "MEE_MI"
9-
STA_PSK = "PinkFloyd1969"
8+
STA_SSID = "FlagTest"
9+
STA_PSK = "0233110330"
1010

1111
# Disable AP interface
1212
ap_if = network.WLAN(network.AP_IF)
@@ -32,10 +32,13 @@
3232

3333
# Handler for path "/cmd?led=[on|off]"
3434
def handleCmd(socket, args):
35+
global ledData
3536
if 'led' in args:
3637
if args['led'] == 'on':
38+
ledData["status"]="ON"
3739
pin.off()
3840
elif args['led'] == 'off':
41+
ledData["status"]="OFF"
3942
pin.on()
4043
ESP8266WebServer.ok(socket, "200", args["led"])
4144
else:
@@ -46,6 +49,12 @@ def handleCmd(socket, args):
4649

4750
# Register handler for each path
4851
ESP8266WebServer.onPath("/cmd", handleCmd)
52+
ESP8266WebServer.setDocPath("/www2")
53+
54+
ledData = {
55+
"status":"Off",
56+
}
57+
ESP8266WebServer.setTplData(ledData)
4958

5059
try:
5160
while True:

www2/index.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<html>
2+
<body>
3+
<h1>This is index.html</h1>
4+
</body>
5+
<html>
6+

www2/index.p.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<html>
2+
<body>
3+
<h1>Status:{status}</h1>
4+
</body>
5+
</html>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy