Skip to content

Commit d9e2e0a

Browse files
committed
Update jupyter.py
1 parent 5c1a316 commit d9e2e0a

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

livekit-rtc/livekit/rtc/jupyter.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import atexit
22
import contextlib
3+
import os
34
from IPython.core.display import HTML
45
from importlib.resources import as_file, files
56

@@ -8,6 +9,20 @@
89

910

1011
def display_room() -> HTML:
12+
try:
13+
from google.colab import secrets
14+
15+
LIVEKIT_JUPYTER_URL = secrets.get("LIVEKIT_JUPYTER_URL")
16+
except ImportError:
17+
LIVEKIT_JUPYTER_URL = os.environ.get("LIVEKIT_JUPYTER_URL")
18+
19+
if not LIVEKIT_JUPYTER_URL:
20+
raise ValueError(
21+
"LIVEKIT_JUPYTER_URL must be set via Google Colab secrets or as an environment variable."
22+
)
23+
1124
index_path = files("livekit.rtc.resources") / "jupyter-html" / "index.html"
1225
index_path = _resource_stack.enter_context(as_file(index_path))
13-
return HTML(index_path.read_text())
26+
html_text = index_path.read_text()
27+
28+
return HTML(html_text)

0 commit comments

Comments
 (0)