diff --git a/wifimgr.py b/wifimgr.py
index 650e88d..300a1ca 100644
--- a/wifimgr.py
+++ b/wifimgr.py
@@ -9,6 +9,109 @@ ap_authmode = 3 # WPA2
NETWORK_PROFILES = 'wifi.dat'
+html_head = """
+
+ WiFi Manager
+
+
+"""
+
wlan_ap = network.WLAN(network.AP_IF)
wlan_sta = network.WLAN(network.STA_IF)
@@ -120,62 +223,58 @@ def handle_root(client):
wlan_sta.active(True)
ssids = sorted(ssid.decode('utf-8') for ssid, *_ in wlan_sta.scan())
send_header(client)
+ client.sendall("")
+ client.sendall(html_head)
client.sendall("""\
-
-
-
- Wi-Fi Client Setup
-
-
-
-
-
-
-
- Your ssid and password information will be saved into the
- "%(filename)s" file in your ESP module for future usage.
- Be careful about security!
-
-
-
-
- Some useful infos:
-
-
+
+ SSID
+
+
+
+ Password
+
+
+
+
+
+
+
+
+ Infos:
+
+
+ Your ssid and password information will be saved into the "{filename}" file in your ESP module for future usage. Be careful about security!
+
+
+ Original code from cpopp/MicroPythonSamples .
+
+
+ This code available at tayfunulu/WiFiManager .
+
+
+
- """ % dict(filename=NETWORK_PROFILES))
+ """.format(filename=NETWORK_PROFILES))
client.close()
@@ -200,17 +299,14 @@ def handle_configure(client, request):
if do_connect(ssid, password):
response = """\
-
-
-
-
- ESP successfully connected to WiFi network %(ssid)s.
-
+ {html_head}
+
+
+ ESP successfully connected to WiFi network "{ssid} "
-
-
+
- """ % dict(ssid=ssid)
+ """.format(html_head=html_head, ssid=ssid)
send_response(client, response)
time.sleep(1)
wlan_ap.active(False)
@@ -227,19 +323,15 @@ def handle_configure(client, request):
else:
response = """\
-
-
-
- ESP could not connect to WiFi network %(ssid)s.
-
+ {html_head}
+
+
+ ESP could not connect to WiFi network "{ssid} "
-
-
-
-
-
+ Go back
+
- """ % dict(ssid=ssid)
+ """.format(html_head=html_head, ssid=ssid)
send_response(client, response)
return False
@@ -284,8 +376,7 @@ def start(port=80):
client, addr = server_socket.accept()
print('client connected from', addr)
try:
- client.settimeout(5.0)
-
+ client.settimeout(15.0)
request = b""
try:
while "\r\n\r\n" not in request: