Sfoglia il codice sorgente

by default we do not show uvicorn access logs

Rodja Trappe 3 anni fa
parent
commit
d277990970
2 ha cambiato i file con 4 aggiunte e 2 eliminazioni
  1. 1 0
      nicegui/config.py
  2. 3 2
      nicegui/run.py

+ 1 - 0
nicegui/config.py

@@ -12,6 +12,7 @@ class Config(BaseModel):
     reload: bool = True
     reload: bool = True
     show: bool = True
     show: bool = True
     interactive: bool = False
     interactive: bool = False
+    uvicron_logging_level = 'warning'
 
 
 
 
 excluded_endings = (
 excluded_endings = (

+ 3 - 2
nicegui/run.py

@@ -8,11 +8,12 @@ import justpy as jp
 if not config.interactive and config.reload and not inspect.stack()[-2].filename.endswith('spawn.py'):
 if not config.interactive and config.reload and not inspect.stack()[-2].filename.endswith('spawn.py'):
     if config.show:
     if config.show:
         webbrowser.open(f'http://{config.host}:{config.port}/')
         webbrowser.open(f'http://{config.host}:{config.port}/')
-    uvicorn.run('nicegui:app', host=config.host, port=config.port, lifespan='on', reload=True)
+    uvicorn.run('nicegui:app', host=config.host, port=config.port, lifespan='on',
+                reload=True, log_level=config.uvicron_logging_level)
     sys.exit()
     sys.exit()
 
 
 def run(self, *, host='0.0.0.0', port=80, title='NiceGUI', favicon='favicon.ico', reload=True, show=True):
 def run(self, *, host='0.0.0.0', port=80, title='NiceGUI', favicon='favicon.ico', reload=True, show=True):
     if config.interactive or reload == False:  # NOTE: if reload == True we already started uvicorn above
     if config.interactive or reload == False:  # NOTE: if reload == True we already started uvicorn above
         if show:
         if show:
             webbrowser.open(f'http://{host if host != "0.0.0.0" else "127.0.0.1"}:{port}/')
             webbrowser.open(f'http://{host if host != "0.0.0.0" else "127.0.0.1"}:{port}/')
-        uvicorn.run(jp.app, host=host, port=port, lifespan='on')
+        uvicorn.run(jp.app, host=host, port=port, log_level=config.uvicron_logging_level, lifespan='on')