v0.0.1
This commit is contained in:
31
web/server.py
Normal file
31
web/server.py
Normal file
@@ -0,0 +1,31 @@
|
||||
import os
|
||||
from http.server import HTTPServer, SimpleHTTPRequestHandler
|
||||
|
||||
# Default error message template
|
||||
DEFAULT_ERROR_MESSAGE = """\
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Single Page Apps for GitHub Pages</title>
|
||||
<script>
|
||||
sessionStorage.redirect = location.href;
|
||||
</script>
|
||||
<meta http-equiv="refresh" content="0;URL='/'">
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
|
||||
class MyHandler(SimpleHTTPRequestHandler):
|
||||
def send_error(self, code, message=None):
|
||||
if code == 404:
|
||||
self.error_message_format = DEFAULT_ERROR_MESSAGE
|
||||
SimpleHTTPRequestHandler.send_error(self, code, message)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
httpd = HTTPServer(('', 4002), MyHandler)
|
||||
print("Serving app on port 4002 ...")
|
||||
httpd.serve_forever()
|
||||
Reference in New Issue
Block a user