Get the URL fragment(s) (part after #) from Streamlit
Project description
Streamlit URL fragment
A fork of ktosiek/streamlit-url-fragment that adds the ability to get the hash as a dictionary if it is in the correct format.
Get the URL fragment (the part of URL after #) in your Streamlit script:
import streamlit as st
from streamlit_url_fragments import get_fragments
current_value = get_fragments()
st.write(f"Current value: {get_fragments()}")
Warning: the first value you'll get will be a None
- that means the component is still loading.
You can wait for the correct value with if current_value is None: st.stop()
.
This fork adds the ability to get the hash as a dictionary if it is in the correct format. Please make sure to test the type returned by the function before using it.
import streamlit as st
from streamlit_url_fragments import get_fragments
current_value = get_fragments()
if isinstance(current_value, dict):
st.write("The function returned a dictionary.")
elif isinstance(current_value, str):
st.write("The function returned a string.")
else:
st.write(f"The function returned an unexpected type: {type(current_value)}")
st.write(f"Current value: {current_value}")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
streamlit_url_fragments-0.1.2.tar.gz
(676.6 kB
view hashes)
Built Distribution
Close
Hashes for streamlit_url_fragments-0.1.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0bad30847b48b28d9c15959434b2727a66bfb14e4d76bcb18f56e5d27f483c09 |
|
MD5 | 6dcc097e0d76005717a7661663854ceb |
|
BLAKE2b-256 | ef63fb005555ea3a9110bf681f84009b1d80e86a531f7193c8c2b7155c815e37 |
Close
Hashes for streamlit_url_fragments-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 357262404e54e39b93d7ee930e6c5212c328dd7fd648d4a010c4f4e0e46dd6f9 |
|
MD5 | c20db4df59cccbc46c0edc4527f4e02a |
|
BLAKE2b-256 | 0076189645f9887dbafbaf10b6453fd5a06b839c5f81d31a1e0e886e2ea9e62e |