Get url from streamlit.app

Hey there, I am using st.experimental_get_query_params() and would like to create a shareable link to the outputs of my app. If I have a fixed url, I can do that by attaching the url params to the base url, but I can’t figure out how the hosted public streamlit.app comes up with the base url. It didn’t seem to be based off the commit hash, so I’m not sure what else it could be.

st.markdown("[share](/?param=value)") should do.

If you actually need to get the full url as a string, you use streamlit-javascript like this:

import streamlit as st
from streamlit_javascript import st_javascript

url = st_javascript("await fetch('').then(r => window.parent.location.href)")

st.write(url)

Alternatively, this package GitHub - aghasemi/streamlit_js_eval: A custom Streamlit component to evaluate arbitrary Javascript expressions has a built-in method:

from streamlit_js_eval import get_page_location

st.write(get_page_location())
3 Likes