Backward compatible with Python 3.4

This commit is contained in:
Shane 2016-10-17 15:37:11 -06:00
parent 70458ea33e
commit ee409479ef
1 changed files with 9 additions and 2 deletions

View File

@ -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: