Fix some junk

This commit is contained in:
Neale Pickett 2020-02-28 15:24:23 -07:00
parent 3d0e73d0e9
commit 6d2c65f9c0
2 changed files with 11 additions and 1 deletions

View File

@ -153,7 +153,7 @@ class MothRequestHandler(http.server.SimpleHTTPRequestHandler):
except KeyError:
self.send_error(
HTTPStatus.NOT_FOUND,
"File Not Found",
"File Not Found: %s" % self.req["filename"],
)
return
@ -233,6 +233,8 @@ class MothRequestHandler(http.server.SimpleHTTPRequestHandler):
HTTPStatus.NOT_IMPLEMENTED,
"Unsupported method (%r)" % self.command,
)
# I don't fully understand why you can't do this inside the class definition.
MothRequestHandler.extensions_map[".mjs"] = "application/ecmascript"

View File

@ -233,6 +233,12 @@ class Puzzle:
except IndexError:
pass
self.files[name] = PuzzleFile(stream, name, not hidden)
elif key == 'files':
for file in val:
path = file["path"]
stream = open(path, "rb")
name = file.get("name") or path
self.files[name] = PuzzleFile(stream, name, not file.get("hidden"))
elif key == 'script':
stream = open(val, 'rb')
self.add_script_stream(stream, val)
@ -400,10 +406,12 @@ class Puzzle:
"""Return a dict packaging of the puzzle."""
files = [fn for fn,f in self.files.items() if f.visible]
hidden = [fn for fn,f in self.files.items() if not f.visible]
return {
'authors': self.get_authors(),
'hashes': self.hashes(),
'files': files,
'hidden': hidden,
'scripts': self.scripts,
'pattern': self.pattern,
'body': self.html_body(),