Forráskód Böngészése

replace welcome message parameter with an opt-out possibility

Falko Schindler 1 éve
szülő
commit
72780b9778
2 módosított fájl, 6 hozzáadás és 5 törlés
  1. 4 3
      nicegui/ui_run.py
  2. 2 2
      nicegui/welcome.py

+ 4 - 3
nicegui/ui_run.py

@@ -45,7 +45,7 @@ def run(*,
         prod_js: bool = True,
         endpoint_documentation: Literal['none', 'internal', 'page', 'all'] = 'none',
         storage_secret: Optional[str] = None,
-        welcome_message: str = 'NiceGUI ready to go ',
+        show_welcome_message: bool = True,
         **kwargs: Any,
         ) -> None:
     """ui.run
@@ -77,7 +77,7 @@ def run(*,
     :param prod_js: whether to use the production version of Vue and Quasar dependencies (default: `True`)
     :param endpoint_documentation: control what endpoints appear in the autogenerated OpenAPI docs (default: 'none', options: 'none', 'internal', 'page', 'all')
     :param storage_secret: secret key for browser-based storage (default: `None`, a value is required to enable ui.storage.individual and ui.storage.browser)
-    :param welcome_message: display a welcome message with URLs to access the NiceGUI app (default: `NiceGUI ready to go `)
+    :param show_welcome_message: whether to show the welcome message (default: `True`)
     :param kwargs: additional keyword arguments are passed to `uvicorn.run`    
     """
     core.app.config.add_run_config(
@@ -105,7 +105,8 @@ def run(*,
     if on_air:
         air.instance = air.Air('' if on_air is True else on_air)
 
-    core.app.on_startup(welcome.print_message(welcome_message))
+    if show_welcome_message:
+        core.app.on_startup(welcome.print_message)
 
     if multiprocessing.current_process().name != 'MainProcess':
         return

+ 2 - 2
nicegui/welcome.py

@@ -13,9 +13,9 @@ def _get_all_ips() -> List[str]:
     return ips
 
 
-async def print_message(welcome_message: str) -> None:
+async def print_message() -> None:
     """Print a welcome message with URLs to access the NiceGUI app."""
-    print(welcome_message, end='', flush=True)
+    print('NiceGUI ready to go ', end='', flush=True)
     host = os.environ['NICEGUI_HOST']
     port = os.environ['NICEGUI_PORT']
     ips = set((await run.io_bound(_get_all_ips)) if host == '0.0.0.0' else [])