diff --git a/readme.md b/readme.md index 50724b08..5a3b06bb 100644 --- a/readme.md +++ b/readme.md @@ -36,6 +36,15 @@ using the local copies. It looks like this: If you are running Windows, there are a build.bat and a build_full.bat for convenience. When the script is done building, the completed site will be in a folder named `htdocs`. +Offline Viewing +--------------- +First compile the files using the `--local-assets` flag, while in the root project directory run +`python start_offline_webserver.py` which starts a local webserver on port 8000 which can be accessed +in your browser by going to the url `http://localhost:8000`. + +If you find that any functionality is missing, please open a pull request. + + File Structure -------------- diff --git a/start_offline_webserver.py b/start_offline_webserver.py new file mode 100644 index 00000000..fe3dfd2b --- /dev/null +++ b/start_offline_webserver.py @@ -0,0 +1,16 @@ +import http.server +import socketserver +import os + +os.chdir('htdocs'); + +class Handler(http.server.SimpleHTTPRequestHandler): + extensions_map = http.server.SimpleHTTPRequestHandler.extensions_map.copy() + extensions_map[''] = 'text/html' + + +host = "localhost" +port = 8000 +with socketserver.TCPServer((host, port), Handler) as httpd: + print(f"serving docs at http://{host}:{port}") + httpd.serve_forever()