From 618100d7b7e250486a13dddf3f6de8049e11fec0 Mon Sep 17 00:00:00 2001 From: John Donaldson Date: Fri, 28 Feb 2020 19:05:24 +0000 Subject: [PATCH] Revert "Hand out the right content-type for .mjs files" This reverts commit 3d0e73d0e907c870f4f4f5038f97e93764f48556. --- devel/devel-server.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/devel/devel-server.py b/devel/devel-server.py index 0534b32..5ec8b68 100755 --- a/devel/devel-server.py +++ b/devel/devel-server.py @@ -7,6 +7,7 @@ import cgi import http.server import io import json +import mimetypes import moth import logging import os @@ -42,6 +43,7 @@ class MothRequestHandler(http.server.SimpleHTTPRequestHandler): except TypeError: super().__init__(request, client_address, server) + # Backport from Python 3.7 def translate_path(self, path): # I guess we just hope that some other thread doesn't call getcwd @@ -158,7 +160,7 @@ class MothRequestHandler(http.server.SimpleHTTPRequestHandler): return self.send_response(200) - self.send_header("Content-Type", self.guess_type(file.name)) + self.send_header("Content-Type", mimetypes.guess_type(file.name)) self.end_headers() shutil.copyfileobj(file.stream, self.wfile) endpoints.append(("/{seed}/content/{cat}/{points}/{filename}", handle_puzzlefile)) @@ -192,7 +194,7 @@ class MothRequestHandler(http.server.SimpleHTTPRequestHandler): self.send_header("Content-Type", "text/html") self.end_headers() self.wfile.write("Your browser was supposed to redirect you to here." % seed) - endpoints.append(("/", handle_index)) + endpoints.append((r"/", handle_index)) def handle_theme_file(self): @@ -233,7 +235,6 @@ class MothRequestHandler(http.server.SimpleHTTPRequestHandler): HTTPStatus.NOT_IMPLEMENTED, "Unsupported method (%r)" % self.command, ) -MothRequestHandler.extensions_map[".mjs"] = "application/ecmascript" if __name__ == '__main__': @@ -278,6 +279,6 @@ if __name__ == '__main__': server.args["base_url"] = args.base server.args["puzzles_dir"] = pathlib.Path(args.puzzles) server.args["theme_dir"] = args.theme - + logging.info("Listening on %s:%d", addr, port) server.serve_forever()