sai-lohith/streamlit_docs huggingface dataset:
DocumentationsearchSearchrocket_launchGet startedInstallationaddFundamentalsaddFirst stepsaddcodeDevelopConceptsaddAPI referenceremovePAGE ELEMENTSWrite and magicaddText elementsremoveHEADINGS & BODYst.titlest.headerst.subheaderst.markdownFORMATTED TEXTst.captionst.codest.dividerst.echost.latexst.textData elementsaddChart elementsaddInput widgetsaddMedia elementsaddLayouts and containersaddChat elementsaddStatus elementsaddThird-party componentsopen_in_newAPPLICATION LOGICNavigation and pagesaddExecution flowaddCaching and stateaddConnections and secretsaddCustom componentsaddUtilitiesaddConfigurationaddTOOLSApp testingaddCommand lineaddTutorialsaddQuick referenceaddweb_assetDeployConceptsaddStreamlit Community CloudaddStreamlit in Snowflakeopen_in_newOther platformsaddschoolKnowledge baseFAQInstalling dependenciesDeployment issuesHome/Develop/API reference/Text elements/st.captionst.captionStreamlit VersionVersion 1.34.0Version 1.33.0Version 1.32.0Version 1.31.0Version 1.30.0Version 1.29.0Version 1.28.0Version 1.27.0Version 1.26.0Version 1.25.0Version 1.24.0Version 1.23.0Version 1.22.0Version 1.21.0Version 1.20.0Version 1.19.0Version 1.18.0Version 1.17.0Version 1.16.0Version 1.15.0Version 1.14.0Version 1.13.0Streamlit in SnowflakeDisplay text in small font.
This should be used for captions, asides, footnotes, sidenotes, and
other explanatory text.
Function signature[source] st.caption(body, unsafe_allow_html=False, *, help=None) Parameters

body
(str)

 
The text to display as Github-flavored Markdown. Syntax
information can be found at: https://github.github.com/gfm.
This also supports:

Emoji shortcodes, such as :+1:  and :sunglasses:.
For a list of all supported codes,
see https://share.streamlit.io/streamlit/emoji-shortcodes.
LaTeX expressions, by wrapping them in "$" or "$$" (the "$$"
must be on their own lines). Supported LaTeX functions are listed
at https://katex.org/docs/supported.html.
Colored text and background colors for text, using the syntax
:color[text to be colored] and :color-background[text to be colored],
respectively. color must be replaced with any of the following
supported colors: blue, green, orange, red, violet, gray/grey, rainbow.
For example, you can use :orange[your text here] or
:blue-background[your text here].



unsafe_allow_html
(bool)

 
By default, any HTML tags found in strings will be escaped and
therefore treated as pure text. This behavior may be turned off by
setting this argument to True.
That said, we strongly advise against it. It is hard to write secure
HTML, so by using this argument you may be compromising your users'
security. For more information, see:
https://github.com/streamlit/streamlit/issues/152


help
(str)

 
An optional tooltip that gets displayed next to the caption.
Examples

import streamlit as st

st.caption('This is a string that explains something above.')
st.caption('A caption with _italics_ :blue[colors] and emojis :sunglasses:')



Previous: st.markdownNext: st.codeforumStill have questions?Our forums are full of helpful information and Streamlit experts.HomeContact UsCommunity© 2024 Snowflake Inc.Cookie policy
DocumentationsearchSearchrocket_launchGet startedInstallationaddFundamentalsaddFirst stepsaddcodeDevelopConceptsaddAPI referenceaddTutorialsaddQuick referenceaddweb_assetDeployConceptsaddStreamlit Community CloudaddStreamlit in Snowflakeopen_in_newOther platformsaddschoolKnowledge baseFAQInstalling dependenciesDeployment issuesHome/Knowledge base/FAQ/What is serializable session state?What is serializable session state?
Serializable Session State
Serialization refers to the process of converting an object or data structure into a format that can be persisted and shared, and allowing you to recover the data’s original structure. Python’s built-in pickle module serializes Python objects to a byte stream ("pickling") and deserializes the stream into an object ("unpickling").
By default, Streamlit’s Session State allows you to persist any Python object for the duration of the session, irrespective of the object’s pickle-serializability. This property lets you store Python primitives such as integers, floating-point numbers, complex numbers and booleans, dataframes, and even lambdas returned by functions. However, some execution environments may require serializing all data in Session State, so it may be useful to detect incompatibility during development, or when the execution environment will stop supporting it in the future.
To that end, Streamlit provides a runner.enforceSerializableSessionState configuration option that, when set to true, only allows pickle-serializable objects in Session State. To enable the option, either create a global or project config file with the following or use it as a command-line flag:
# .streamlit/config.toml
[runner]
enforceSerializableSessionState = true

By "pickle-serializable", we mean calling pickle.dumps(obj) should not raise a PicklingError exception. When the config option is enabled, adding unserializable data to session state should result in an exception. E.g.,
import streamlit as st

def unserializable_data():
		return lambda x: x

#👇 results in an exception when enforceSerializableSessionState is on
st.session_state.unserializable = unserializable_data()

Previous: Why does Streamlit restrict nested st.columns?Next: Installing dependenciesforumStill have questions?Our forums are full of helpful information and Streamlit experts.HomeContact UsCommunity© 2024 Snowflake Inc.Cookie policy
DocumentationsearchSearchrocket_launchGet startedInstallationaddFundamentalsaddFirst stepsaddcodeDevelopConceptsaddAPI referenceaddTutorialsaddQuick referenceaddweb_assetDeployConceptsaddStreamlit Community CloudaddStreamlit in Snowflakeopen_in_newOther platformsaddschoolKnowledge baseFAQInstalling dependenciesDeployment issuesHome/Knowledge base/FAQ/How to download a file in Streamlit?How to download a file in Streamlit?
Use the st.download_button widget that is natively built into Streamlit. Check out a sample app demonstrating how you can use st.download_button to download common file formats.
Example usage
import streamlit as st

# Text files

text_contents = '''
Foo, Bar
123, 456
789, 000
'''

# Different ways to use the API

st.download_button('Download CSV', text_contents, 'text/csv')
st.download_button('Download CSV', text_contents)  # Defaults to 'text/plain'

with open('myfile.csv') as f:
   st.download_button('Download CSV', f)  # Defaults to 'text/plain'

# ---
# Binary files

binary_contents = b'whatever'

# Different ways to use the API

st.download_button('Download file', binary_contents)  # Defaults to 'application/octet-stream'

with open('myfile.zip', 'rb') as f:
   st.download_button('Download Zip', f, file_name='archive.zip')  # Defaults to 'application/octet-stream'

# You can also grab the return value of the button,
# just like with any other button.

if st.download_button(...):
   st.write('Thanks for downloading!')

Additional resources:

https://blog.streamlit.io/0-88-0-release-notes/
https://streamlit-release-demos-0-88streamlit-app-0-88-v8ram3.streamlit.app/
https://docs.streamlit.io/develop/api-reference/widgets/st.download_button
Previous: Enabling camera access in your browserNext: How to download a Pandas DataFrame as a CSV?forumStill have questions?Our forums are full of helpful information and Streamlit experts.HomeContact UsCommunity© 2024 Snowflake Inc.Cookie policy
DocumentationsearchSearchrocket_launchGet startedInstallationaddFundamentalsaddFirst stepsaddcodeDevelopConceptsaddAPI referenceaddTutorialsaddQuick referenceaddweb_assetDeployConceptsaddStreamlit Community CloudaddStreamlit in Snowflakeopen_in_newOther platformsaddschoolKnowledge baseFAQInstalling dependenciesDeployment issuesHome/Knowledge base/Installing dependencies/ImportError libGL.so.1 cannot open shared object file No such file or directoryImportError libGL.so.1 cannot open shared object file No such file or directory
Problem
You receive the error ImportError libGL.so.1 cannot open shared object file No such file or directory when using OpenCV in your app deployed on Streamlit Community Cloud.
Solution
If you use OpenCV in your app, include opencv-python-headless in your requirements file on Streamlit Community Cloud in place of opencv_contrib_python and opencv-python.
If opencv-python is a required (non-optional) dependency of your app or a dependency of a library used in your app, the above solution is not applicable. Instead, you can use the following solution:
Create a packages.txt file in your repo with the following line to install the apt-get dependency libgl:
libgl1
Previous: How to install a package not on PyPI or Conda but available on GitHubNext: ModuleNotFoundError No module namedforumStill have questions?Our forums are full of helpful information and Streamlit experts.HomeContact UsCommunity© 2024 Snowflake Inc.Cookie policy
DocumentationsearchSearchrocket_launchGet startedInstallationaddFundamentalsaddFirst stepsaddcodeDevelopConceptsaddAPI referenceaddTutorialsaddQuick referenceaddweb_assetDeployConceptsaddStreamlit Community CloudaddStreamlit in Snowflakeopen_in_newOther platformsaddschoolKnowledge baseFAQInstalling dependenciesDeployment issuesHome/Knowledge base/FAQ/How can I make Streamlit watch for changes in other modules I'm importing in my app?How can I make Streamlit watch for changes in other modules I'm importing in my app?
By default, Streamlit only watches modules contained in the current directory of the main app module. You can track other modules by adding the parent directory of each module to the PYTHONPATH.
export PYTHONPATH=$PYTHONPATH:/path/to/module
streamlit run your_script.py
Previous: Sanity checksNext: What browsers does Streamlit support?forumStill have questions?Our forums are full of helpful information and Streamlit experts.HomeContact UsCommunity© 2024 Snowflake Inc.Cookie policy
DocumentationsearchSearchrocket_launchGet startedInstallationaddFundamentalsaddFirst stepsaddcodeDevelopConceptsremoveCOREArchitecture & executionaddMultipage appsaddApp designaddADDITIONALConnections and secretsaddCustom componentsaddConfiguration and themingremoveConfiguration optionsHTTPS supportServing static filesCustomize your themeApp testingaddAPI referenceaddTutorialsaddQuick referenceaddweb_assetDeployConceptsaddStreamlit Community CloudaddStreamlit in Snowflakeopen_in_newOther platformsaddschoolKnowledge baseFAQInstalling dependenciesDeployment issuesHome/Develop/Concepts/Configuration and theming/HTTPS supportHTTPS support
Many apps need to be accessed with SSL / TLS protocol or https://.
We recommend performing SSL termination in a reverse proxy or load balancer for self-hosted and production use cases, not directly in the app. Streamlit Community Cloud uses this approach, and every major cloud and app hosting platform should allow you to configure it and provide extensive documentation. You can find some of these platforms in our Deployment tutorials.
To terminate SSL in your Streamlit app, you must configure server.sslCertFile and server.sslKeyFile. Learn how to set config options in Configuration.
Details on usage

The configuration value should be a local file path to a cert file and key file. These must be available at the time the app starts.
Both server.sslCertFile and server.sslKeyFile must be specified. If only one is specified, your app will exit with an error.
This feature will not work in Community Cloud. Community Cloud already serves your app with TLS.

priority_highWarningIn a production environment, we recommend performing SSL termination by the load balancer or the reverse proxy, not using this option. The use of this option in Streamlit has not gone through extensive security audits or performance tests.
Example usage
# .streamlit/config.toml

[server]
sslCertFile = '/path/to/certchain.pem'
sslKeyFile = '/path/to/private.key'
Previous: Configuration optionsNext: Serving static filesforumStill have questions?Our forums are full of helpful information and Streamlit experts.HomeContact UsCommunity© 2024 Snowflake Inc.Cookie policy
DocumentationsearchSearchrocket_launchGet startedInstallationaddFundamentalsaddFirst stepsaddcodeDevelopConceptsaddAPI referenceaddTutorialsaddQuick referenceaddweb_assetDeployConceptsaddStreamlit Community CloudaddStreamlit in Snowflakeopen_in_newOther platformsaddschoolKnowledge baseFAQInstalling dependenciesDeployment issuesHome/Knowledge baseKnowledge base
The knowledge base is a self-serve library of tips, step-by-step tutorials, and articles that answer your questions about creating and deploying Streamlit apps.
quizFAQ Here are some frequently asked questions about using Streamlit.downloadingInstalling dependencies. If you run into problems installing dependencies for your Streamlit apps, we've got you covered.reportDeployment issues. Have questions about deploying Streamlit apps to the cloud? This section covers deployment-related issues.Previous: DeployNext: FAQforumStill have questions?Our forums are full of helpful information and Streamlit experts.HomeContact UsCommunity© 2024 Snowflake Inc.Cookie policy
DocumentationsearchSearchrocket_launchGet startedInstallationaddFundamentalsaddFirst stepsaddcodeDevelopConceptsaddAPI referenceaddTutorialsaddQuick referenceaddweb_assetDeployConceptsaddStreamlit Community CloudaddStreamlit in Snowflakeopen_in_newOther platformsaddschoolKnowledge baseFAQInstalling dependenciesDeployment issuesHome/Knowledge base/Deployment issues/How do I increase the upload limit of st.file_uploader on Streamlit Community Cloud?How do I increase the upload limit of st.file_uploader on Streamlit Community Cloud?
Overview
By default, files uploaded using st.file_uploader() are limited to 200MB. You can configure this using the server.maxUploadSize config option.
Streamlit provides four different ways to set configuration options:

In a global config file at ~/.streamlit/config.toml for macOS/Linux or %userprofile%/.streamlit/config.toml for Windows:
[server]
maxUploadSize = 200


In a per-project config file at $CWD/.streamlit/config.toml, where $CWD is the folder you're running Streamlit from.
Through STREAMLIT_* environment variables, such as:
export STREAMLIT_SERVER_MAX_UPLOAD_SIZE=200


As flags on the command line when running streamlit run:
streamlit run your_script.py --server.maxUploadSize 200



Which of the four options should you choose for an app deployed to Streamlit Community Cloud? 🤔
Solution
When deploying your app to Streamlit Community Cloud, you should use option 1. Namely, set the maxUploadSize config option in a global config file (.streamlit/config.toml) uploaded to your app's GitHub repo. 🎈
For example, to increase the upload limit to 400MB, upload a .streamlit/config.toml file containing the following lines to your app's GitHub repo:
[server]
maxUploadSize = 400

Relevant resources

Streamlit drag and drop capping at 200MB, need workaround
File uploader widget API
How to set Streamlit configuration options
Previous: Does Streamlit support the WSGI Protocol? (aka Can I deploy Streamlit with gunicorn?)Next: Invoking a Python subprocess in a deployed Streamlit appforumStill have questions?Our forums are full of helpful information and Streamlit experts.HomeContact UsCommunity© 2024 Snowflake Inc.Cookie policy
DocumentationsearchSearchrocket_launchGet startedInstallationaddFundamentalsaddFirst stepsaddcodeDevelopConceptsremoveCOREArchitecture & executionaddMultipage appsaddApp designaddADDITIONALConnections and secretsaddCustom componentsremoveIntro to custom componentsCreate a ComponentPublish a ComponentLimitationsComponent galleryopen_in_newConfiguration and themingaddApp testingaddAPI referenceaddTutorialsaddQuick referenceaddweb_assetDeployConceptsaddStreamlit Community CloudaddStreamlit in Snowflakeopen_in_newOther platformsaddschoolKnowledge baseFAQInstalling dependenciesDeployment issuesHome/Develop/Concepts/Custom components/LimitationsLimitations of custom components
How do Streamlit Components differ from functionality provided in the base Streamlit package?

Streamlit Components are wrapped up in an iframe, which gives you the ability to do whatever you want (within the iframe) using any web technology you like.

What types of things aren't possible with Streamlit Components?
Because each Streamlit Component gets mounted into its own sandboxed iframe, this implies a few limitations on what is possible with Components:

Can't communicate with other Components: Components can’t contain (or otherwise communicate with) other components, so Components cannot be used to build something like a grid layout.
Can't modify CSS: A Component can’t modify the CSS that the rest of the Streamlit app uses, so you can't create something to put the app in dark mode, for example.
Can't add/remove elements: A Component can’t add or remove other elements of a Streamlit app, so you couldn't make something to remove the app menu, for example.

My Component seems to be blinking/stuttering...how do I fix that?
Currently, no automatic debouncing of Component updates is performed within Streamlit. The Component creator themselves can decide to rate-limit the updates they send back to Streamlit.Previous: Publish a ComponentNext: Component galleryforumStill have questions?Our forums are full of helpful information and Streamlit experts.HomeContact UsCommunity© 2024 Snowflake Inc.Cookie policy
DocumentationsearchSearchrocket_launchGet startedInstallationaddFundamentalsaddFirst stepsaddcodeDevelopConceptsaddAPI referenceremovePAGE ELEMENTSWrite and magicaddText elementsaddData elementsaddChart elementsremoveSIMPLEst.area_chartst.bar_chartst.line_chartst.mapst.scatter_chartADVANCEDst.altair_chartst.bokeh_chartst.graphviz_chartst.plotly_chartst.pydeck_chartst.pyplotst.vega_lite_chartInput widgetsaddMedia elementsaddLayouts and containersaddChat elementsaddStatus elementsaddThird-party componentsopen_in_newAPPLICATION LOGICNavigation and pagesaddExecution flowaddCaching and stateaddConnections and secretsaddCustom componentsaddUtilitiesaddConfigurationaddTOOLSApp testingaddCommand lineaddTutorialsaddQuick referenceaddweb_assetDeployConceptsaddStreamlit Community CloudaddStreamlit in Snowflakeopen_in_newOther platformsaddschoolKnowledge baseFAQInstalling dependenciesDeployment issuesHome/Develop/API reference/Chart elements/st.graphviz_chartst.graphviz_chartStreamlit VersionVersion 1.34.0Version 1.33.0Version 1.32.0Version 1.31.0Version 1.30.0Version 1.29.0Version 1.28.0Version 1.27.0Version 1.26.0Version 1.25.0Version 1.24.0Version 1.23.0Version 1.22.0Version 1.21.0Version 1.20.0Version 1.19.0Version 1.18.0Version 1.17.0Version 1.16.0Version 1.15.0Version 1.14.0Version 1.13.0Streamlit in SnowflakeDisplay a graph using the dagre-d3 library.
Function signature[source] st.graphviz_chart(figure_or_dot, use_container_width=False) Parameters

figure_or_dot
(graphviz.dot.Graph, graphviz.dot.Digraph, str)

 
The Graphlib graph object or dot string to display


use_container_width
(bool)

 
If True, set the chart width to the column width. This takes
precedence over the figure's native width value.
Example

import streamlit as st
import graphviz

# Create a graphlib graph object
graph = graphviz.Digraph()
graph.edge('run', 'intr')
graph.edge('intr', 'runbl')
graph.edge('runbl', 'run')
graph.edge('run', 'kernel')
graph.edge('kernel', 'zombie')
graph.edge('kernel', 'sleep')
graph.edge('kernel', 'runmem')
graph.edge('sleep', 'swap')
graph.edge('swap', 'runswap')
graph.edge('runswap', 'new')
graph.edge('runswap', 'runmem')
graph.edge('new', 'runmem')
graph.edge('sleep', 'runmem')

st.graphviz_chart(graph)

Or you can render the chart from the graph using GraphViz's Dot
language:

st.graphviz_chart('''
    digraph {
        run -> intr
        intr -> runbl
        runbl -> run
        run -> kernel
        kernel -> zombie
        kernel -> sleep
        kernel -> runmem
        sleep -> swap
        swap -> runswap
        runswap -> new
        runswap -> runmem
        new -> runmem
        sleep -> runmem
    }
''')

Built with Streamlit 🎈Fullscreen open_in_new

Previous: st.bokeh_chartNext: st.plotly_chartforumStill have questions?Our forums are full of helpful information and Streamlit experts.HomeContact UsCommunity© 2024 Snowflake Inc.Cookie policy
DocumentationsearchSearchrocket_launchGet startedInstallationaddFundamentalsaddFirst stepsaddcodeDevelopConceptsaddAPI referenceaddTutorialsaddQuick referenceaddweb_assetDeployConceptsaddStreamlit Community CloudaddStreamlit in Snowflakeopen_in_newOther platformsaddschoolKnowledge baseFAQInstalling dependenciesDeployment issuesHome/Knowledge base/Deployment issues/How do I deploy Streamlit on a domain so it appears to run on a regular port (i.e. port 80)?How do I deploy Streamlit on a domain so it appears to run on a regular port (i.e. port 80)?
Problem
You want to deploy a Streamlit app on a domain so it appears to run on port 80.
Solution


You should use a reverse proxy to forward requests from a webserver like Apache or Nginx to the port where your Streamlit app is running. You can accomplish this in several different ways. The simplest way is to forward all requests sent to your domain so that your Streamlit app appears as the content of your website.


Another approach is to configure your webserver to forward requests to designated subfolders (e.g. http://awesomestuff.net/streamlitapp) to different Streamlit apps on the same domain, as in this example config for Nginx submitted by a Streamlit community member.


Related forum posts:

https://discuss.streamlit.io/t/permission-denied-in-ec2-port-80/798/3
https://discuss.streamlit.io/t/how-to-use-streamlit-with-nginx/378/7
Previous: How can I deploy multiple Streamlit apps on different subdomains?Next: Does Streamlit support the WSGI Protocol? (aka Can I deploy Streamlit with gunicorn?)forumStill have questions?Our forums are full of helpful information and Streamlit experts.HomeContact UsCommunity© 2024 Snowflake Inc.Cookie policy
DocumentationsearchSearchrocket_launchGet startedInstallationaddFundamentalsaddFirst stepsaddcodeDevelopConceptsaddAPI referenceaddTutorialsaddQuick referenceaddweb_assetDeployConceptsaddStreamlit Community CloudaddStreamlit in Snowflakeopen_in_newOther platformsaddschoolKnowledge baseFAQInstalling dependenciesDeployment issuesHome/Knowledge base/Deployment issues/How can I deploy multiple Streamlit apps on different subdomains?How can I deploy multiple Streamlit apps on different subdomains?
Problem
You want to deploy multiple Streamlit apps on different subdomains.
Solution
Like running your Streamlit app on more common ports such as 80, subdomains are handled by a web server like Apache or Nginx:


Set up a web server on a machine with a public IP address, then use a DNS server to point all desired subdomains to your webserver's IP address


Configure your web server to route requests for each subdomain to the different ports that your Streamlit apps are running on


For example, let’s say you had two Streamlit apps called Calvin and Hobbes. App Calvin is running on port 8501. You set up app Hobbes to run on port 8502. Your webserver would then be set up to "listen" for requests on subdomains calvin.somedomain.com and hobbes.subdomain.com, and route requests to port 8501 and 8502, respectively.
Check out these two tutorials for Apache2 and Nginx that deal with setting up a webserver to redirect subdomains to different ports:

Apache2 subdomains
NGinx subdomains
Previous: Authentication without SSONext: How do I deploy Streamlit on a domain so it appears to run on a regular port (i.e. port 80)?forumStill have questions?Our forums are full of helpful information and Streamlit experts.HomeContact UsCommunity© 2024 Snowflake Inc.Cookie policy