diff --git a/examples/fastapi/frontend.py b/examples/fastapi/frontend.py index 4a7ac30ef..9669298c4 100644 --- a/examples/fastapi/frontend.py +++ b/examples/fastapi/frontend.py @@ -14,5 +14,5 @@ def show(): ui.run_with( fastapi_app, - storage_secret='pick your private secret here' # NOTE setting a secret is optional but allows for persistent storage per user + storage_secret='pick your private secret here', # NOTE setting a secret is optional but allows for persistent storage per user ) diff --git a/nicegui/helpers.py b/nicegui/helpers.py index 6f71c25d8..8e36819dc 100644 --- a/nicegui/helpers.py +++ b/nicegui/helpers.py @@ -12,8 +12,8 @@ from starlette.middleware import Middleware from starlette.middleware.sessions import SessionMiddleware -from nicegui.storage import RequestTrackingMiddleware from . import background_tasks, globals +from .storage import RequestTrackingMiddleware if TYPE_CHECKING: from .client import Client @@ -91,7 +91,7 @@ def in_thread(host: str, port: int) -> None: def set_storage_secret(storage_secret: Optional[str] = None) -> None: - """Set storage_secret for ui.run() and run_with.""" + """Set storage_secret and add request tracking middleware.""" if any(m.cls == SessionMiddleware for m in globals.app.user_middleware): # NOTE not using "add_middleware" because it would be the wrong order globals.app.user_middleware.append(Middleware(RequestTrackingMiddleware))