mirror of https://gitlab.com/gpvkt/twitchtts.git
Add 404 handling
This commit is contained in:
parent
40552acb45
commit
aae0d3c6a9
17
tts.py
17
tts.py
|
@ -225,7 +225,7 @@ class HTTPserv(BaseHTTPRequestHandler):
|
||||||
html = fh.read()
|
html = fh.read()
|
||||||
self.wfile.write(html)
|
self.wfile.write(html)
|
||||||
|
|
||||||
if self.path == '/tts.js':
|
elif self.path == '/tts.js':
|
||||||
self.send_response(200)
|
self.send_response(200)
|
||||||
self.send_header('Content-type', 'text/javascript')
|
self.send_header('Content-type', 'text/javascript')
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
|
@ -233,7 +233,7 @@ class HTTPserv(BaseHTTPRequestHandler):
|
||||||
html = fh.read()
|
html = fh.read()
|
||||||
self.wfile.write(html)
|
self.wfile.write(html)
|
||||||
|
|
||||||
if self.path == '/jquery.js':
|
elif self.path == '/jquery.js':
|
||||||
self.send_response(200)
|
self.send_response(200)
|
||||||
self.send_header('Content-type', 'text/javascript')
|
self.send_header('Content-type', 'text/javascript')
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
|
@ -241,7 +241,7 @@ class HTTPserv(BaseHTTPRequestHandler):
|
||||||
html = fh.read()
|
html = fh.read()
|
||||||
self.wfile.write(html)
|
self.wfile.write(html)
|
||||||
|
|
||||||
if self.path == '/bootstrap.min.css':
|
elif self.path == '/bootstrap.min.css':
|
||||||
self.send_response(200)
|
self.send_response(200)
|
||||||
self.send_header('Content-type', 'text/css')
|
self.send_header('Content-type', 'text/css')
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
|
@ -249,7 +249,7 @@ class HTTPserv(BaseHTTPRequestHandler):
|
||||||
html = fh.read()
|
html = fh.read()
|
||||||
self.wfile.write(html)
|
self.wfile.write(html)
|
||||||
|
|
||||||
if self.path.startswith('/tts_queue'):
|
elif self.path.startswith('/tts_queue'):
|
||||||
tts_json = ""
|
tts_json = ""
|
||||||
tts = {}
|
tts = {}
|
||||||
self.send_response(200)
|
self.send_response(200)
|
||||||
|
@ -269,7 +269,7 @@ class HTTPserv(BaseHTTPRequestHandler):
|
||||||
tts_json = json.dumps(tts)
|
tts_json = json.dumps(tts)
|
||||||
self.wfile.write(bytes(str(tts_json)+"\n", "utf-8"))
|
self.wfile.write(bytes(str(tts_json)+"\n", "utf-8"))
|
||||||
|
|
||||||
if self.path.startswith('/tts_done'):
|
elif self.path.startswith('/tts_done'):
|
||||||
get_params = parse_qs(self.path)
|
get_params = parse_qs(self.path)
|
||||||
if '/tts_done?id' in get_params:
|
if '/tts_done?id' in get_params:
|
||||||
logging.info("Removing message from queue")
|
logging.info("Removing message from queue")
|
||||||
|
@ -284,6 +284,13 @@ class HTTPserv(BaseHTTPRequestHandler):
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
self.wfile.write(bytes("Internal Server error\n", "utf-8"))
|
self.wfile.write(bytes("Internal Server error\n", "utf-8"))
|
||||||
|
|
||||||
|
else:
|
||||||
|
self.send_response(404)
|
||||||
|
self.send_header('Server', 'TTS')
|
||||||
|
self.send_header('Content-type', 'text/plain')
|
||||||
|
self.end_headers()
|
||||||
|
self.wfile.write(bytes("File not found.\n", "utf-8"))
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def http_serve_forever(httpd):
|
def http_serve_forever(httpd):
|
||||||
|
|
Loading…
Reference in New Issue