|
@@ -1,10 +1,12 @@
|
|
|
from typing import Optional
|
|
|
|
|
|
from fastapi import FastAPI
|
|
|
+from starlette.middleware.sessions import SessionMiddleware
|
|
|
|
|
|
from nicegui import globals
|
|
|
from nicegui.language import Language
|
|
|
from nicegui.nicegui import handle_shutdown, handle_startup
|
|
|
+from nicegui.storage import RequestTrackingMiddleware
|
|
|
|
|
|
|
|
|
def run_with(
|
|
@@ -17,6 +19,7 @@ def run_with(
|
|
|
binding_refresh_interval: float = 0.1,
|
|
|
exclude: str = '',
|
|
|
mount_path: str = '/',
|
|
|
+ storage_secret: Optional[str] = None,
|
|
|
) -> None:
|
|
|
globals.ui_run_has_been_called = True
|
|
|
globals.title = title
|
|
@@ -28,6 +31,9 @@ def run_with(
|
|
|
globals.excludes = [e.strip() for e in exclude.split(',')]
|
|
|
globals.tailwind = True
|
|
|
|
|
|
+ app.add_middleware(RequestTrackingMiddleware)
|
|
|
+ app.add_middleware(SessionMiddleware, secret_key=storage_secret)
|
|
|
+
|
|
|
app.on_event('startup')(lambda: handle_startup(with_welcome_message=False))
|
|
|
app.on_event('shutdown')(lambda: handle_shutdown())
|
|
|
|