Skip to content

Commit

Permalink
let make run serve 404.html
Browse files Browse the repository at this point in the history
  • Loading branch information
brandenburg committed Dec 21, 2023
1 parent b7102d0 commit 4602f5f
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions srv/server.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
import http.server
from http.server import HTTPServer, BaseHTTPRequestHandler
from http.server import SimpleHTTPRequestHandler
import socketserver

PORT = 8000

Handler = http.server.SimpleHTTPRequestHandler

class Handler(SimpleHTTPRequestHandler):
def send_error(self, code, message=None):
if code == 404:
with open("404.html", "rb") as err_msg:
page404 = err_msg.read()

self.send_response(code)
self.send_header("Connection", "close")
self.send_header("Content-Type", "text/html")
self.send_header("Content-Length", str(len(page404)))
self.end_headers()
self.wfile.write(page404)
else:
SimpleHTTPRequestHandler.send_error(self, code, message)


Handler.extensions_map={
'.manifest': 'text/cache-manifest',
Expand Down

0 comments on commit 4602f5f

Please sign in to comment.