Skip to main content

Get the URL fragment(s) (part after #) from Streamlit

Project description

Streamlit URL fragment

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


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.0.tar.gz (676.5 kB view details)

Uploaded Source

Built Distribution

streamlit_url_fragments-0.1.0-py3-none-any.whl (687.4 kB view details)

Uploaded Python 3

File details

Details for the file streamlit_url_fragments-0.1.0.tar.gz.

File metadata

File hashes

Hashes for streamlit_url_fragments-0.1.0.tar.gz
Algorithm Hash digest
SHA256 598324e02898b1fd0f8805d8b37a06ff75b10b14ca9d9fd128cb42310a461529
MD5 ace58a138fa33a4755808527782866a7
BLAKE2b-256 6048f7bd2e3b1b9b6286d67d4884e6c9e839f96e69e2d247bc108c479e7579b4

See more details on using hashes here.

File details

Details for the file streamlit_url_fragments-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for streamlit_url_fragments-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e3349f6cdb52b6a4c21f48daa02f783a6eb91655eec3d1d330f5537e5d46f1d0
MD5 096d6f9836be70e513894bec780f4fe0
BLAKE2b-256 b67b21c1e02693a971de0b8b8128495fcb5d6849373f4d4eb0eb4f606597d166

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page