diff --git a/pelican/tools/templates/tasks.py.jinja2 b/pelican/tools/templates/tasks.py.jinja2 index 0362eba7..1b02d3c9 100644 --- a/pelican/tools/templates/tasks.py.jinja2 +++ b/pelican/tools/templates/tasks.py.jinja2 @@ -39,7 +39,8 @@ CONFIG = { 'github_pages_branch': '{{github_pages_branch}}', 'commit_message': "'Publish site on {}'".format(datetime.date.today().isoformat()), {% endif %} - # Port for `serve` + # Host and port for `serve` + 'host': 'localhost', 'port': 8000, } @@ -67,17 +68,17 @@ def regenerate(c): @task def serve(c): - """Serve site at http://localhost:$PORT/ (default port is 8000)""" + """Serve site at http://$HOST:$PORT/ (default is localhost:8000)""" class AddressReuseTCPServer(RootedHTTPServer): allow_reuse_address = True server = AddressReuseTCPServer( CONFIG['deploy_path'], - ('', CONFIG['port']), + (CONFIG['host'], CONFIG['port']), ComplexHTTPRequestHandler) - sys.stderr.write('Serving on port {port} ...\n'.format(**CONFIG)) + sys.stderr.write('Serving at {host}:{port} ...\n'.format(**CONFIG)) server.serve_forever() @task @@ -111,8 +112,8 @@ def livereload(c): for extension in static_file_extensions: static_file = '{0}/static/**/*{1}'.format(theme_path, extension) server.watch(static_file, lambda: build(c)) - # Serve output path on configured port - server.serve(port=CONFIG['port'], root=CONFIG['deploy_path']) + # Serve output path on configured host and port + server.serve(host=CONFIG['host'], port=CONFIG['port'], root=CONFIG['deploy_path']) {% if cloudfiles %} @task