mirror of https://github.com/dirtbags/moth.git
Backward compatible with Python 3.4
This commit is contained in:
parent
70458ea33e
commit
ee409479ef
|
@ -8,7 +8,14 @@ import pathlib
|
||||||
import puzzles
|
import puzzles
|
||||||
import socketserver
|
import socketserver
|
||||||
|
|
||||||
HTTPStatus = http.server.HTTPStatus
|
|
||||||
|
#HTTPStatus = http.server.HTTPStatus
|
||||||
|
if hasattr(http.server, 'HTTPStatus'):
|
||||||
|
HTTPStatus = http.HTTPStatus
|
||||||
|
else:
|
||||||
|
class HTTPStatus:
|
||||||
|
NOT_FOUND = 404
|
||||||
|
OK = 200
|
||||||
|
|
||||||
def page(title, body):
|
def page(title, body):
|
||||||
return """<!DOCTYPE html>
|
return """<!DOCTYPE html>
|
||||||
|
@ -125,7 +132,7 @@ you are a fool.
|
||||||
return None
|
return None
|
||||||
content = mdpage(text)
|
content = mdpage(text)
|
||||||
|
|
||||||
self.send_response(http.server.HTTPStatus.OK)
|
self.send_response(HTTPStatus.OK)
|
||||||
self.send_header("Content-type", "text/html; encoding=utf-8")
|
self.send_header("Content-type", "text/html; encoding=utf-8")
|
||||||
self.send_header("Content-Length", len(content))
|
self.send_header("Content-Length", len(content))
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue