Change not found behaviour to just redirect to index

pull/13/head
TilCreator 2018-05-28 20:48:34 +02:00
rodzic 9d3094862a
commit 3754bb9911
1 zmienionych plików z 8 dodań i 5 usunięć

Wyświetl plik

@ -99,8 +99,11 @@ def do_connect(ssid, password):
return connected 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("HTTP/1.0 {} OK\r\n".format(status_code))
if redirect:
client.sendall("Location: {}\r\n".format(redirect))
else:
client.sendall("Content-Type: text/html\r\n") client.sendall("Content-Type: text/html\r\n")
if content_length is not None: if content_length is not None:
client.sendall("Content-Length: {}\r\n".format(content_length)) client.sendall("Content-Length: {}\r\n".format(content_length))
@ -236,7 +239,7 @@ def handle_configure(client, request):
def handle_not_found(client, url): 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(): def stop():