Browse Source

Merge pull request #516 from Lucas-C/serve-open-browser

sigal serve --browser : open in your default browser
pull/518/head
Simon Conseil 2 years ago committed by GitHub
parent
commit
cf15fcca82
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 7
      src/sigal/__main__.py

7
src/sigal/__main__.py

@ -25,6 +25,7 @@ import pathlib
import socketserver
import sys
import time
import webbrowser
from http import server
import click
@ -227,7 +228,8 @@ def build(
show_default=True,
help="Configuration file",
)
def serve(destination, port, config):
@option("-b", "--browser", is_flag=True, help="Open in your default browser")
def serve(destination, port, config, browser):
"""Run a simple web server."""
if os.path.exists(destination):
pass
@ -253,6 +255,9 @@ def serve(destination, port, config):
httpd = socketserver.TCPServer(("", port), Handler, False)
print(f" * Running on http://127.0.0.1:{port}/")
if browser:
webbrowser.open(f"http://127.0.0.1:{port}/")
try:
httpd.allow_reuse_address = True
httpd.server_bind()

Loading…
Cancel
Save