Skip to content

Commit

Permalink
code review
Browse files Browse the repository at this point in the history
  • Loading branch information
falkoschindler committed Jun 12, 2023
1 parent d453953 commit 47b3ad3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/fastapi/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
4 changes: 2 additions & 2 deletions nicegui/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 47b3ad3

Please sign in to comment.