-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
27 lines (21 loc) · 709 Bytes
/
utils.py
File metadata and controls
27 lines (21 loc) · 709 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
"""Utility functions for the app."""
import urllib
import streamlit as st
def get_base_url() -> str:
"""Returns the base URL of the current Streamlit app."""
session = st.runtime.get_instance()._session_mgr.list_active_sessions()[0]
return urllib.parse.urlunparse(
[
session.client.request.protocol,
session.client.request.host,
"",
"",
"",
"",
]
)
def get_shared_chat_id() -> int | None:
"""Returns the shared chat ID from the URL."""
if "shared_chat_id" not in st.experimental_get_query_params():
return None
return int(st.experimental_get_query_params()["shared_chat_id"][0])