Skip to content

Commit

Permalink
Merge pull request #145 from cuppajoeman/offline-mode
Browse files Browse the repository at this point in the history
  • Loading branch information
BSVino authored Nov 13, 2023
2 parents 96aaa5a + ea8dbe5 commit c5f8a8b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
9 changes: 9 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
--------------

Expand Down
16 changes: 16 additions & 0 deletions start_offline_webserver.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit c5f8a8b

Please sign in to comment.