Skip to content

Commit 40c9a92

Browse files
committed
correct relative path problems.
1 parent 69b4a08 commit 40c9a92

File tree

5 files changed

+22
-9
lines changed

5 files changed

+22
-9
lines changed

ESP8266WebServer.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@ def ok(socket, code, *args):
8585
raise TypeError("ok() takes 3 or 4 positional arguments but "+ str(len(args)+2) +" were given")
8686
socket.write("HTTP/1.1 " + code + " OK\r\n")
8787
socket.write("Content-Type: " + content_type + "\r\n\r\n")
88-
if __fileExist(msg):
89-
filePath = msg
90-
__sendPage(socket, filePath)
91-
else:
92-
socket.write(msg)
88+
# if __fileExist(msg):
89+
# filePath = msg
90+
# __sendPage(socket, filePath)
91+
# else:
92+
socket.write(msg)
9393

9494
def __fileExist(path):
9595
"""Check for file existence
@@ -157,10 +157,17 @@ def handle(socket):
157157
else:
158158
err(socket, "404", "Not Found")
159159
return
160+
socket.write("HTTP/1.1 302 Found\r\n")
161+
socket.write("Location: " + filePath + "\r\n\r\n")
162+
return
160163

161164
# Responds the header first
162165
socket.write("HTTP/1.1 200 OK\r\n")
163166
socket.write("Content-Type: text/html\r\n\r\n")
167+
# if filePath.endswith(".css"):
168+
# socket.write("Content-Type: text/css\r\n\r\n")
169+
# else:
170+
# socket.write("Content-Type: text/html\r\n\r\n")
164171
# Responds the file content
165172
if filePath.endswith(".p.html"):
166173
print("template file.")

Simple_led.py

Lines changed: 2 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 = "FlagTest"
9-
STA_PSK = "0233110330"
8+
STA_SSID = "MEE_MI"
9+
STA_PSK = "PinkFloyd1969"
1010

1111
# Disable AP interface
1212
ap_if = network.WLAN(network.AP_IF)

TestWebServer.py

Lines changed: 2 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 = "SSID"
9-
STA_PSK = "PASSWORD"
8+
STA_SSID = "MEE_MI"
9+
STA_PSK = "PinkFloyd1969"
1010

1111
# Disable AP interface
1212
ap_if = network.WLAN(network.AP_IF)

www2/index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<html>
2+
<head>
3+
<link rel="stylesheet" href="test.css">
4+
</head>
25
<body>
36
<h1>This is index.html</h1>
47
</body>

www2/test.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
h1 {
2+
color: blue;
3+
}

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