mirror of https://github.com/dirtbags/moth.git
Merge branch 'devel' of https://github.com/dirtbags/moth into devel
This commit is contained in:
commit
b540861097
|
@ -7,6 +7,7 @@ import cgi
|
||||||
import http.server
|
import http.server
|
||||||
import io
|
import io
|
||||||
import json
|
import json
|
||||||
|
import mimetypes
|
||||||
import moth
|
import moth
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
@ -42,6 +43,7 @@ class MothRequestHandler(http.server.SimpleHTTPRequestHandler):
|
||||||
except TypeError:
|
except TypeError:
|
||||||
super().__init__(request, client_address, server)
|
super().__init__(request, client_address, server)
|
||||||
|
|
||||||
|
|
||||||
# Backport from Python 3.7
|
# Backport from Python 3.7
|
||||||
def translate_path(self, path):
|
def translate_path(self, path):
|
||||||
# I guess we just hope that some other thread doesn't call getcwd
|
# I guess we just hope that some other thread doesn't call getcwd
|
||||||
|
@ -158,7 +160,7 @@ class MothRequestHandler(http.server.SimpleHTTPRequestHandler):
|
||||||
return
|
return
|
||||||
|
|
||||||
self.send_response(200)
|
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()
|
self.end_headers()
|
||||||
shutil.copyfileobj(file.stream, self.wfile)
|
shutil.copyfileobj(file.stream, self.wfile)
|
||||||
endpoints.append(("/{seed}/content/{cat}/{points}/{filename}", handle_puzzlefile))
|
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.send_header("Content-Type", "text/html")
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
self.wfile.write("Your browser was supposed to redirect you to <a href=\"%s/\">here</a>." % seed)
|
self.wfile.write("Your browser was supposed to redirect you to <a href=\"%s/\">here</a>." % seed)
|
||||||
endpoints.append(("/", handle_index))
|
endpoints.append((r"/", handle_index))
|
||||||
|
|
||||||
|
|
||||||
def handle_theme_file(self):
|
def handle_theme_file(self):
|
||||||
|
|
Loading…
Reference in New Issue