@@ -28,21 +28,23 @@ def cli() -> None:
2828 'env variable AIO_LIVERELOAD' )
2929browser_cache_help = ("When disabled (the default), sends no-cache headers to "
3030 "disable browser caching." )
31+ bind_address_help = "Network address to listen, default localhost. env variable: AIO_BIND_ADDRESS"
3132
3233
3334@cli .command ()
3435@click .argument ('path' , type = _dir_existing , required = True )
3536@click .option ('--livereload/--no-livereload' , envvar = 'AIO_LIVERELOAD' , default = True , help = livereload_help )
37+ @click .option ("-b" , "--bind" , "bind_address" , envvar = "AIO_BIND_ADDRESS" , default = "localhost" , help = bind_address_help )
3638@click .option ('-p' , '--port' , default = 8000 , type = int )
3739@click .option ('-v' , '--verbose' , is_flag = True , help = verbose_help )
3840@click .option ("--browser-cache/--no-browser-cache" , envvar = "AIO_BROWSER_CACHE" , default = False ,
3941 help = browser_cache_help )
40- def serve (path : str , livereload : bool , port : int , verbose : bool , browser_cache : bool ) -> None :
42+ def serve (path : str , livereload : bool , bind_address : str , port : int , verbose : bool , browser_cache : bool ) -> None :
4143 """
4244 Serve static files from a directory.
4345 """
4446 setup_logging (verbose )
45- run_app (** serve_static (static_path = path , livereload = livereload , port = port ,
47+ run_app (** serve_static (static_path = path , livereload = livereload , bind_address = bind_address , port = port ,
4648 browser_cache = browser_cache ))
4749
4850
@@ -55,7 +57,7 @@ def serve(path: str, livereload: bool, port: int, verbose: bool, browser_cache:
5557 "added to the server, instead of via signals (this is the default on Windows). "
5658 "env variable: AIO_SHUTDOWN_BY_URL" )
5759host_help = ('host used when referencing livereload and static files, if blank host is taken from the request header '
58- ' with default of localhost . env variable AIO_HOST' )
60+ " with default of bind network address . env variable AIO_HOST" )
5961app_factory_help = ('name of the app factory to create an aiohttp.web.Application with, if missing default app-factory '
6062 'names are tried. This can be either a function with signature '
6163 '"def create_app(loop): -> Application" or "def create_app(): -> Application" '
@@ -75,6 +77,7 @@ def serve(path: str, livereload: bool, port: int, verbose: bool, browser_cache:
7577@click .option ('--livereload/--no-livereload' , envvar = 'AIO_LIVERELOAD' , default = None , help = livereload_help )
7678@click .option ('--host' , default = INFER_HOST , help = host_help )
7779@click .option ('--app-factory' , 'app_factory_name' , envvar = 'AIO_APP_FACTORY' , help = app_factory_help )
80+ @click .option ("-b" , "--bind" , "bind_address" , envvar = "AIO_BIND_ADDRESS" , default = "localhost" , help = bind_address_help )
7881@click .option ('-p' , '--port' , 'main_port' , envvar = 'AIO_PORT' , type = click .INT , help = port_help )
7982@click .option ('--aux-port' , envvar = 'AIO_AUX_PORT' , type = click .INT , help = aux_port_help )
8083@click .option ('-v' , '--verbose' , is_flag = True , help = verbose_help )
0 commit comments