kopia lustrzana https://github.com/tayfunulu/WiFiManager
Change not found behaviour to just redirect to index
rodzic
9d3094862a
commit
3754bb9911
13
wifimgr.py
13
wifimgr.py
|
@ -99,11 +99,14 @@ def do_connect(ssid, password):
|
|||
return connected
|
||||
|
||||
|
||||
def send_header(client, status_code=200, content_length=None ):
|
||||
def send_header(client, status_code=200, content_length=None, redirect=None):
|
||||
client.sendall("HTTP/1.0 {} OK\r\n".format(status_code))
|
||||
client.sendall("Content-Type: text/html\r\n")
|
||||
if content_length is not None:
|
||||
client.sendall("Content-Length: {}\r\n".format(content_length))
|
||||
if redirect:
|
||||
client.sendall("Location: {}\r\n".format(redirect))
|
||||
else:
|
||||
client.sendall("Content-Type: text/html\r\n")
|
||||
if content_length is not None:
|
||||
client.sendall("Content-Length: {}\r\n".format(content_length))
|
||||
client.sendall("\r\n")
|
||||
|
||||
|
||||
|
@ -236,7 +239,7 @@ def handle_configure(client, request):
|
|||
|
||||
|
||||
def handle_not_found(client, url):
|
||||
send_response(client, "Path not found: {}".format(url), status_code=404)
|
||||
send_response(client, "", status_code=307, redirect='/')
|
||||
|
||||
|
||||
def stop():
|
||||
|
|
Ładowanie…
Reference in New Issue