mirror of https://github.com/dirtbags/moth.git
Hand out the right content-type for .mjs files
This commit is contained in:
parent
bdfbe527de
commit
3d0e73d0e9
|
@ -7,7 +7,6 @@ import cgi
|
|||
import http.server
|
||||
import io
|
||||
import json
|
||||
import mimetypes
|
||||
import moth
|
||||
import logging
|
||||
import os
|
||||
|
@ -43,7 +42,6 @@ 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
|
||||
|
@ -160,7 +158,7 @@ class MothRequestHandler(http.server.SimpleHTTPRequestHandler):
|
|||
return
|
||||
|
||||
self.send_response(200)
|
||||
self.send_header("Content-Type", mimetypes.guess_type(file.name))
|
||||
self.send_header("Content-Type", self.guess_type(file.name))
|
||||
self.end_headers()
|
||||
shutil.copyfileobj(file.stream, self.wfile)
|
||||
endpoints.append(("/{seed}/content/{cat}/{points}/{filename}", handle_puzzlefile))
|
||||
|
@ -194,7 +192,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 <a href=\"%s/\">here</a>." % seed)
|
||||
endpoints.append((r"/", handle_index))
|
||||
endpoints.append(("/", handle_index))
|
||||
|
||||
|
||||
def handle_theme_file(self):
|
||||
|
@ -235,6 +233,7 @@ class MothRequestHandler(http.server.SimpleHTTPRequestHandler):
|
|||
HTTPStatus.NOT_IMPLEMENTED,
|
||||
"Unsupported method (%r)" % self.command,
|
||||
)
|
||||
MothRequestHandler.extensions_map[".mjs"] = "application/ecmascript"
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Reference in New Issue