@@ -94,7 +94,17 @@ def cli(
9494 show_default = True ,
9595 help = (
9696 "set a required authentication token/password for the notebook; "
97- "if not set, no token/password is required"
97+ "if not set, no token/password is required (env: NOTEBOOK_TOKEN)"
98+ ),
99+ )
100+ @click .option (
101+ "--base-url" ,
102+ envvar = "NOTEBOOK_BASE_URL" ,
103+ default = None ,
104+ show_default = True ,
105+ help = (
106+ "explicit base URL prefix to pass through to marimo on notebook launch "
107+ "(env: NOTEBOOK_BASE_URL)"
98108 ),
99109)
100110@click .pass_context
@@ -110,6 +120,7 @@ def run(
110120 host : str ,
111121 port : int ,
112122 token : str | None ,
123+ base_url : str | None ,
113124) -> None :
114125 """Launch notebook in 'run' or 'edit' mode."""
115126 notebook_dir_path = resolve_notebook_directory (
@@ -126,6 +137,7 @@ def run(
126137 token = token ,
127138 notebook_path = notebook_path ,
128139 requirements_file = requirements_file ,
140+ base_url = base_url ,
129141 )
130142
131143 logger .info (f"launching notebook '{ full_notebook_path } ' with args { cmd } " )
@@ -230,6 +242,7 @@ def prepare_run_command(
230242 token : str | None ,
231243 notebook_path : str ,
232244 requirements_file : Path | None ,
245+ base_url : str | None = None ,
233246) -> list [str ]:
234247 """Build the shell command used to launch a marimo notebook via `uv run`.
235248
@@ -253,6 +266,8 @@ def prepare_run_command(
253266 - notebook_path: path to the marimo notebook file.
254267 - requirements_file: optional path to a requirements file for `uv` (enables
255268 `--with-requirements`).
269+ - base_url: base URL path launched notebook will listen on
270+ e.g. host:port/<base_url>
256271 """
257272 # start with `uv run` so marimo executes in a managed Python environment
258273 cmd : list [str ] = ["uv" , "run" ]
@@ -281,6 +296,10 @@ def prepare_run_command(
281296 else :
282297 cmd += ["--no-token" ]
283298
299+ # set base url flag if passed
300+ if base_url :
301+ cmd += ["--base-url" , base_url ]
302+
284303 # path to the notebook is the final positional argument
285304 cmd += [str (notebook_path )]
286305
0 commit comments