feat(factory): serve dashboard at root and create project repos refs NOISSUE
This commit is contained in:
@@ -5,6 +5,7 @@ The dashboard shown is from dashboard_ui.py with real-time database data.
|
||||
"""
|
||||
|
||||
from fastapi import FastAPI
|
||||
from fastapi.responses import RedirectResponse
|
||||
|
||||
from nicegui import app, ui
|
||||
|
||||
@@ -22,13 +23,24 @@ def init(fastapi_app: FastAPI, storage_secret: str = 'Secr2t!') -> None:
|
||||
storage_secret: Optional secret for persistent user storage.
|
||||
"""
|
||||
|
||||
@ui.page('/show')
|
||||
def show():
|
||||
def render_dashboard_page() -> None:
|
||||
create_dashboard()
|
||||
|
||||
|
||||
# NOTE dark mode will be persistent for each user across tabs and server restarts
|
||||
ui.dark_mode().bind_value(app.storage.user, 'dark_mode')
|
||||
ui.checkbox('dark mode').bind_value(app.storage.user, 'dark_mode')
|
||||
|
||||
@ui.page('/')
|
||||
def home() -> None:
|
||||
render_dashboard_page()
|
||||
|
||||
@ui.page('/show')
|
||||
def show() -> None:
|
||||
render_dashboard_page()
|
||||
|
||||
@fastapi_app.get('/dashboard', include_in_schema=False)
|
||||
def dashboard_redirect() -> RedirectResponse:
|
||||
return RedirectResponse(url='/', status_code=307)
|
||||
|
||||
ui.run_with(
|
||||
fastapi_app,
|
||||
|
||||
Reference in New Issue
Block a user