Matt Goodall avatar Matt Goodall committed a996daf

Make "serve" action's hostname configurable.

Sometimes 'localhost' binds to an ipv6 interface (and causes some browsers
problems) but it's also useful to bind to a public interface for testing with
other browsers.

Comments (0)

Files changed (1)

blatter/__init__.py

         print "Try it out with 'blatter serve' and 'blatter blat'."
     print "Done."
 
-def action_serve(port=('p', 8008), use_reloader=True, debugger=True):
+def action_serve(port=('p', 8008), hostname=('h', 'localhost'),
+                 use_reloader=True, debugger=True):
     """Start a local web server for content viewing."""
     from werkzeug import serving
 
     app = top_level_factory(config, debugger=debugger)
 
     if os.environ.get('WERKZEUG_RUN_MAIN') != 'true':
-        print "Blatter server starting for:\n\thttp://localhost:%s%s\n" % (
-            port, config.url_prefix)
-    serving.run_simple('localhost', port, app, use_reloader)
+        print "Blatter server starting for:\n\thttp://%s:%s%s\n" % (
+            hostname, port, config.url_prefix)
+    serving.run_simple(hostname, port, app, use_reloader)
 
 def action_generate(verbose=('v', False)):
     """Process all content in the site folder and place in the output folder."""
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.