Skip to content

Commit

Permalink
Print message instead of opening command line browser
Browse files Browse the repository at this point in the history
If the browser is www-browser, opening it will pause Python,
which stops Nikola serving pages.
  • Loading branch information
ChrisJefferson committed Mar 31, 2021
1 parent 8cc31e0 commit 018a05c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions nikola/plugins/command/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,11 @@ def _execute(self, options, args):
# Some browsers fail to load 0.0.0.0 (Issue #2755)
if sa[0] == '0.0.0.0':
server_url = "http://127.0.0.1:{1}/".format(*sa)
self.logger.info("Opening {0} in the default web browser...".format(server_url))
webbrowser.open(server_url)
if getattr(webbrowser.get(), "name", "") == "www-browser":
self.logger.info("Unable to open web browser, as Python could only find a terminal browser...")
else:
self.logger.info("Opening {0} in the default web browser...".format(server_url))
webbrowser.open(server_url)
if options['detach']:
self.detached = True
OurHTTPRequestHandler.quiet = True
Expand Down

0 comments on commit 018a05c

Please sign in to comment.