Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow specifying a custom port with --port #152

Open
wants to merge 1 commit into
base: mainline
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions start_offline_webserver.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import argparse
import http.server
import socketserver
import os
Expand All @@ -9,8 +10,11 @@ class Handler(http.server.SimpleHTTPRequestHandler):
extensions_map[''] = 'text/html'


parser = argparse.ArgumentParser()
parser.add_argument('--port', type=int, default=8000)
args = parser.parse_args()

host = "localhost"
port = 8000
with socketserver.TCPServer((host, port), Handler) as httpd:
print(f"serving docs at http://{host}:{port}")
with socketserver.TCPServer((host, args.port), Handler) as httpd:
print(f"serving docs at http://{host}:{args.port}")
httpd.serve_forever()