@@ -187,12 +187,16 @@ def cli():
187187
188188
189189@cli.command ()
190- @click.option (" --host" , default = " 0.0.0.0 " , show_default = True , help = " Bind host. " ) # noqa: S104
191- @click.option (" --port" , default = 8000 , show_default = True , help = " Bind port." )
192- @click.option (" --reload" , is_flag = True , default = False , help = " Enable auto-reload." )
193- def run (host : str , port : int , reload : bool ) -> None :
190+ @click.option (" --host" , default = None , show_default = True , help = " Bind host (defaults to FAST_API.SERVE_HOST). " )
191+ @click.option (" --port" , default = None , type = int , show_default = True , help = " Bind port (defaults to FAST_API.SERVE_PORT) ." )
192+ @click.option (" --reload/--no-reload " , default = None , help = " Enable auto-reload (defaults to FAST_API.RELOAD) ." )
193+ def run (host : str | None , port : int | None , reload : bool | None ) -> None :
194194 """ Start the FastAPI development server."""
195- uvicorn.run(" manage:create_app" , factory = True , host = host, port = port, reload = reload )
195+ config = BaseConfig.global_config()
196+ serve_host = host or config.FAST_API .SERVE_HOST
197+ serve_port = port or config.FAST_API .SERVE_PORT
198+ serve_reload = config.FAST_API .RELOAD if reload is None else reload
199+ uvicorn.run(" manage:create_app" , factory = True , host = serve_host, port = serve_port, reload = serve_reload)
196200
197201
198202if __name__ == " __main__" :
0 commit comments