mirror of https://github.com/dirtbags/moth.git
Merge pull request #122 from dirtbags/mjs
Add a MIME-type for .mjs files
This commit is contained in:
commit
8809580355
|
@ -1,6 +1,5 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import asyncio
|
||||
import cgitb
|
||||
import html
|
||||
import cgi
|
||||
|
@ -43,6 +42,13 @@ class MothRequestHandler(http.server.SimpleHTTPRequestHandler):
|
|||
except TypeError:
|
||||
super().__init__(request, client_address, server)
|
||||
|
||||
# Why isn't this the default?!
|
||||
def guess_type(self, path):
|
||||
mtype, encoding = mimetypes.guess_type(path)
|
||||
if encoding:
|
||||
return "%s; encoding=%s" % (mtype, encoding)
|
||||
else:
|
||||
return mtype
|
||||
|
||||
# Backport from Python 3.7
|
||||
def translate_path(self, path):
|
||||
|
@ -285,6 +291,8 @@ if __name__ == '__main__':
|
|||
|
||||
logging.basicConfig(level=log_level)
|
||||
|
||||
mimetypes.add_type("application/javascript", ".mjs")
|
||||
|
||||
server = MothServer((addr, port), MothRequestHandler)
|
||||
server.args["base_url"] = args.base
|
||||
server.args["puzzles_dir"] = pathlib.Path(args.puzzles)
|
||||
|
|
Loading…
Reference in New Issue