|
@@ -2,19 +2,18 @@ import inspect
|
|
|
import sys
|
|
|
import webbrowser
|
|
|
import uvicorn
|
|
|
-from .config import config # NOTE: before justpy
|
|
|
-import justpy as jp
|
|
|
+from . import globals
|
|
|
|
|
|
-if not config.interactive and config.reload and not inspect.stack()[-2].filename.endswith('spawn.py'):
|
|
|
+if not globals.config.interactive and globals.config.reload and not inspect.stack()[-2].filename.endswith('spawn.py'):
|
|
|
|
|
|
- if config.show:
|
|
|
- webbrowser.open(f'http://{config.host}:{config.port}/')
|
|
|
- uvicorn.run('nicegui:app', host=config.host, port=config.port, lifespan='on', reload=True)
|
|
|
+ if globals.config.show:
|
|
|
+ webbrowser.open(f'http://{globals.config.host}:{globals.config.port}/')
|
|
|
+ uvicorn.run('nicegui:app', host=globals.config.host, port=globals.config.port, lifespan='on', reload=True)
|
|
|
sys.exit()
|
|
|
|
|
|
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 globals.config.interactive or reload == False: # NOTE: if reload == True we already started uvicorn above
|
|
|
if show:
|
|
|
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(globals.app, host=host, port=port, lifespan='on')
|