mirror of https://gitlab.com/gpvkt/twitchtts.git
Add 404 handling
This commit is contained in:
parent
3ae4eecd04
commit
5aa13fb815
17
tts.py
17
tts.py
|
@ -225,7 +225,7 @@ class HTTPserv(BaseHTTPRequestHandler):
|
|||
html = fh.read()
|
||||
self.wfile.write(html)
|
||||
|
||||
if self.path == '/tts.js':
|
||||
elif self.path == '/tts.js':
|
||||
self.send_response(200)
|
||||
self.send_header('Content-type', 'text/javascript')
|
||||
self.end_headers()
|
||||
|
@ -233,7 +233,7 @@ class HTTPserv(BaseHTTPRequestHandler):
|
|||
html = fh.read()
|
||||
self.wfile.write(html)
|
||||
|
||||
if self.path == '/jquery.js':
|
||||
elif self.path == '/jquery.js':
|
||||
self.send_response(200)
|
||||
self.send_header('Content-type', 'text/javascript')
|
||||
self.end_headers()
|
||||
|
@ -241,7 +241,7 @@ class HTTPserv(BaseHTTPRequestHandler):
|
|||
html = fh.read()
|
||||
self.wfile.write(html)
|
||||
|
||||
if self.path == '/bootstrap.min.css':
|
||||
elif self.path == '/bootstrap.min.css':
|
||||
self.send_response(200)
|
||||
self.send_header('Content-type', 'text/css')
|
||||
self.end_headers()
|
||||
|
@ -249,7 +249,7 @@ class HTTPserv(BaseHTTPRequestHandler):
|
|||
html = fh.read()
|
||||
self.wfile.write(html)
|
||||
|
||||
if self.path.startswith('/tts_queue'):
|
||||
elif self.path.startswith('/tts_queue'):
|
||||
tts_json = ""
|
||||
tts = {}
|
||||
self.send_response(200)
|
||||
|
@ -269,7 +269,7 @@ class HTTPserv(BaseHTTPRequestHandler):
|
|||
tts_json = json.dumps(tts)
|
||||
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)
|
||||
if '/tts_done?id' in get_params:
|
||||
logging.info("Removing message from queue")
|
||||
|
@ -284,6 +284,13 @@ class HTTPserv(BaseHTTPRequestHandler):
|
|||
self.end_headers()
|
||||
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
|
||||
|
||||
def http_serve_forever(httpd):
|
||||
|
|
Loading…
Reference in New Issue