My team build and host some streamlit apps in our own server with limited bandwidth. It works well at the beginning. But when we show the app in a seminar and the audiences access our apps at the same time, it becomes extremely slow to open.
So I make this streamlit-hotfix
to dump streamlit static assets and patch index.html
to load assets from CDN by the following commands:
# dump assets to a folder
st-hotfix cdn dump streamit ./path/to/streamlit-assets
# now you can distribut streamlit-assets with CDN, for example jsDelivr
# e.g: https://cdn.jsdelivr.net/gh/link89/assets@0.1.0/cdn/streamlit/
# then you can patch streamlit to load assets from CDN
st-hotfix cdn patch streamlit --cdn_url https://cdn.jsdelivr.net/gh/link89/assets@0.1.0/cdn/streamlit/
I believe this can be implement in streamlit with tornado template engine and some configurable options, but it am not sure if the community would like it. So I just build this tool to apply patch to the installed package.
You can learn more about how it works from the github project: link89/streamlit-hotfix: A command line tool to provide advanced features (CDN, etc) for streamlit by apply patch to the installed packages. (github.com).
Reference: