Browse Source

code review

Falko Schindler 1 năm trước cách đây
mục cha
commit
47b3ad3b2b
2 tập tin đã thay đổi với 3 bổ sung3 xóa
  1. 1 1
      examples/fastapi/frontend.py
  2. 2 2
      nicegui/helpers.py

+ 1 - 1
examples/fastapi/frontend.py

@@ -14,5 +14,5 @@ def init(fastapi_app: FastAPI) -> None:
 
     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
     )

+ 2 - 2
nicegui/helpers.py

@@ -12,8 +12,8 @@ from typing import TYPE_CHECKING, Any, Awaitable, Callable, Optional, Tuple, Uni
 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 schedule_browser(host: str, port: int) -> Tuple[threading.Thread, threading.
 
 
 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))