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.1.tar.gz
(676.6 kB
view hashes)
Built Distribution
Close
Hashes for streamlit_url_fragments-0.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 471afbba86dea6d9695a3ca6ae36b4d301606b92992304d955fb84dcdc6530ef |
|
MD5 | b1c4024d5f7a0b5ae0067fbd8c6dc7e6 |
|
BLAKE2b-256 | 171700154df310388d3a0c8e5f38694c2d5e7216d333ce06a2e1daa9479801f1 |
Close
Hashes for streamlit_url_fragments-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a83fcfceb23651bc79412cca60d96fd9b0d75a784fab04a1178d108d08420f4 |
|
MD5 | 949732de9923ba65162f5b3a3e4526e7 |
|
BLAKE2b-256 | b313e69278a4c5a277b122aeb72ffe000b216dd6de350cf84623274e6ee83a01 |