mirror of
https://github.com/natankeddem/bale.git
synced 2026-04-23 06:50:41 +00:00
improve startup and data handling
This commit is contained in:
16
main.py
16
main.py
@@ -5,9 +5,18 @@ logger = logging.getLogger(__name__)
|
||||
import os
|
||||
|
||||
if not os.path.exists("data"):
|
||||
os.makedirs("data")
|
||||
logger.warning("Could not find 'data' directory, verify bind mounts.")
|
||||
if os.path.exists(".nicegui"):
|
||||
logger.warning("Creating 'data' directory symlink.")
|
||||
os.symlink(".nicegui", "data", target_is_directory=True)
|
||||
else:
|
||||
logger.warning("Creating 'data' directory, settings will not be persistent.")
|
||||
os.makedirs("data")
|
||||
else:
|
||||
logger.warning("Found 'data' directory.")
|
||||
os.environ.setdefault("NICEGUI_STORAGE_PATH", "data")
|
||||
from nicegui import ui # type: ignore
|
||||
|
||||
from nicegui import app, ui # type: ignore
|
||||
|
||||
ui.card.default_style("max-width: none")
|
||||
ui.card.default_props("flat bordered")
|
||||
@@ -22,7 +31,8 @@ from bale import page, logo, scheduler
|
||||
|
||||
|
||||
if __name__ in {"__main__", "__mp_main__"}:
|
||||
app.on_startup(lambda: print(f"Starting bale, bound to the following addresses {', '.join(app.urls)}.", flush=True))
|
||||
page.build()
|
||||
s = scheduler.Scheduler()
|
||||
ui.timer(0.1, s.start, once=True)
|
||||
ui.run(title="bale", favicon=logo.favicon, dark=True, reload=False)
|
||||
ui.run(title="bale", favicon=logo.favicon, dark=True, reload=False, show=False, show_welcome_message=False)
|
||||
|
||||
Reference in New Issue
Block a user