Skip to main content

streamlit-ws-localstorage

Finally a simple synchronous way of accessing localStorage from your Streamlit app.

Downloads

Why

I tried using extra-streamlit-components but found it too complex, because of the way Streamlit components works. Since the communication between the browser and streamlit app is async, your app is run multiple times, and nested if else blocks may not work properly. A simple call to get all cookies causes the app to be run 4 times in total. And the first call to get all cookies returns an empty dictionary which needs to be handled in the code.

Looking at the complexity, I thought it would be easier to write a synchronous commmunication.

How to run

Using it is fairly simple:

import streamlit as st
from streamlit_ws_localstorage import injectWebsocketCode, getOrCreateUID

# Main call to the api, returns a communication object
conn = injectWebsocketCode(hostPort='linode.liquidco.in', uid=getOrCreateUID())

st.write('setting into localStorage')
ret = conn.setLocalStorageVal(key='k1', val='v1')
st.write('ret: ' + ret)

st.write('getting from localStorage')
ret = conn.getLocalStorageVal(key='k1')
st.write('ret: ' + ret)

You can use the linode.liquidco.in websocket relay server for testing. Alternately run your websocket relay server from the code in websocket-server/ws_server.py

Video demo

https://user-images.githubusercontent.com/544881/185042658-43dd3c58-a086-4457-a042-9d4d895e34ba.mp4

Metadata

Release files for streamlit-ws-localstorage 1.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for streamlit-ws-localstorage 1.0.6
File Size Uploaded Provenance Actions
streamlit_ws_localstorage-1.0.6.tar.gz 5.4 kB Without provenance Details for streamlit_ws_localstorage-1.0.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for streamlit-ws-localstorage 1.0.6
File Interpreter ABI Platform Actions
streamlit_ws_localstorage-1.0.6-py2-none-any.whl Python 2 none any Details for streamlit_ws_localstorage-1.0.6-py2-none-any.whl

Total release size: 25.2 kB

Release files / streamlit_ws_localstorage-1.0.6.tar.gz

Download URL streamlit_ws_localstorage-1.0.6.tar.gz
Size 5.4 kB
Tags Source
SHA-256 checksum
How to use checksums
76606d13628522838386a73755c9a4da5475da72ea0ca6cf83e2ab482e152dad
BLAKE2b-256 checksum
How to use checksums
b417c7eacd4aa35be20b6897d387c7a30a2ba96ae9afe6ba3fa8ad9842dfd7e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.7.9

Release files / streamlit_ws_localstorage-1.0.6-py2-none-any.whl

Download URL streamlit_ws_localstorage-1.0.6-py2-none-any.whl
Size 19.8 kB
Tags Python 2
SHA-256 checksum
How to use checksums
9f7719b9278e0009a9e0cf564fdc7a2752bc76485abf52b7cdbf35da339ae2c7
BLAKE2b-256 checksum
How to use checksums
5368be51032a3048d2b3b6be59b2833695b64401c782c55e89a65903950cd316
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.7.9

Security for streamlit-ws-localstorage 1.0.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page