Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

starlette compat (#1535)

Akshay Agrawal686201289e3b
diff --git a/marimo/_server/api/auth.py b/marimo/_server/api/auth.py
index 4325659ed7..da701fecc6 100644
--- a/marimo/_server/api/auth.py
+++ b/marimo/_server/api/auth.py
@@ -6,7 +6,9 @@ import secrets
import typing
from typing import TYPE_CHECKING, Any, Dict, Optional
+import starlette
import starlette.status as status
+from packaging import version
from starlette.datastructures import Secret
from starlette.exceptions import HTTPException
from starlette.middleware.sessions import SessionMiddleware
@@ -170,16 +172,28 @@ class CustomSessionMiddleware(SessionMiddleware):
self.original_session_cookie = session_cookie
- super().__init__(
- app,
- secret_key,
- session_cookie,
- max_age,
- path,
- same_site,
- https_only,
- domain,
- )
+ if version.parse(starlette.__version__) >= version.parse("0.32.0"):
+ # Domain was added in 0.32.0; we currently don't use it.
+ super().__init__(
+ app,
+ secret_key,
+ session_cookie,
+ max_age,
+ path,
+ same_site,
+ https_only,
+ domain,
+ )
+ else:
+ super().__init__(
+ app,
+ secret_key,
+ session_cookie,
+ max_age,
+ path,
+ same_site,
+ https_only,
+ )
async def __call__(
self, scope: Scope, receive: Receive, send: Send