kopia lustrzana https://github.com/tayfunulu/WiFiManager
cleanup server socket and client close
rodzic
6b7e885bb0
commit
ff4ad2524a
|
@ -199,6 +199,7 @@ def stop():
|
||||||
|
|
||||||
if server_socket:
|
if server_socket:
|
||||||
server_socket.close()
|
server_socket.close()
|
||||||
|
server_socket = None
|
||||||
|
|
||||||
|
|
||||||
def start(port=80):
|
def start(port=80):
|
||||||
|
@ -227,13 +228,12 @@ def start(port=80):
|
||||||
while True:
|
while True:
|
||||||
|
|
||||||
if wlan_sta.isconnected():
|
if wlan_sta.isconnected():
|
||||||
client.close
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
client, addr = server_socket.accept()
|
client, addr = server_socket.accept()
|
||||||
client.settimeout(5.0)
|
|
||||||
|
|
||||||
print('client connected from', addr)
|
print('client connected from', addr)
|
||||||
|
try:
|
||||||
|
client.settimeout(5.0)
|
||||||
|
|
||||||
request = b""
|
request = b""
|
||||||
try:
|
try:
|
||||||
|
@ -245,7 +245,6 @@ def start(port=80):
|
||||||
print("Request is: {}".format(request))
|
print("Request is: {}".format(request))
|
||||||
if "HTTP" not in request:
|
if "HTTP" not in request:
|
||||||
# skip invalid requests
|
# skip invalid requests
|
||||||
client.close()
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# version 1.9 compatibility
|
# version 1.9 compatibility
|
||||||
|
@ -262,4 +261,5 @@ def start(port=80):
|
||||||
else:
|
else:
|
||||||
handle_not_found(client, url)
|
handle_not_found(client, url)
|
||||||
|
|
||||||
|
finally:
|
||||||
client.close()
|
client.close()
|
||||||
|
|
Ładowanie…
Reference in New Issue