diff --git a/README.md b/README.md index 5a00fdfc3..23e7727a3 100644 --- a/README.md +++ b/README.md @@ -149,7 +149,7 @@ Do you want to add a new page to the docs? 1. First, decide which section the page should live in (Streamlit Library, Streamlit Community Cloud, or Knowledge Base). -2. Next, navigate to the relevant folder and subfolder within `content/` and create a `.md` file whose filename mirrors the title of the page. E.g. For a page titled "Create a component", navigate to `content/library/components/` and create a file named `create-component.md`. +2. Next, navigate to the relevant folder and subfolder within `content/` and create a `.md` file whose filename mirrors the title of the page. E.g. For a page titled "Create a component", navigate to `content/develop/concepts/custom-components/` and create a file named `create-component.md`. ### Structure of the `.md` file @@ -159,12 +159,12 @@ Now that you've decided where the file should live and have named the file, it's Every `.md` file has front matter at the very top that defines the page title which appears in the browser tab bar, and the URL slug which appears after the slash in `docs.streamlit.io/` and `localhost:3000/`. -E.g. For a page titled "Create a component" that should exist at `docs.streamlit.io/library/components/create`, the front matter at the top of `create-component.md` is: +E.g. For a page titled "Create a component" that should exist at `docs.streamlit.io/develop/concepts/custom-components/create`, the front matter at the top of `create-component.md` is: ```markdown --- title: Create a Component -slug: /library/components/create +slug: /develop/concepts/custom-components/create --- ``` @@ -272,19 +272,19 @@ If you need to regenerate all function signatures, across all versions, delete t Suppose a new Streamlit release includes a `st.my_chart` function that you want to include in the "Chart elements" section of the API Reference: 1. Run `make docstrings` -2. Create Markdown file (`my_chart.md`) in `content/library/api/charts/` +2. Create Markdown file (`my_chart.md`) in `content/develop/api/charts/` 3. Add the following to `my_chart.md`: ```markdown --- title: st.my_chart - slug: /library/api-reference/charts/st.my_chart + slug: /develop/api-reference/charts/st.my_chart --- ``` -4. Add the following under the "Chart elements" heading in `content/library/api/api-reference.md`: +4. Add the following under the "Chart elements" heading in `content/develop/api/api-reference.md`: 1. A RefCard MDX function containing the URL slug defined in `my_chart.md` . This is the card that will appear on the API Reference landing page. 2. An Image MDX function containing alt text and the location of the image to be displayed on the card. 3. A bold heading that will appear on the card (`#### Heading`). It appears below the card image. @@ -292,7 +292,7 @@ Suppose a new Streamlit release includes a `st.my_chart` function that you want 5. A code block illustrating how to use `st.my_chart`. It appears below the card description and has a Copy icon that when clicked copies the code block to the users' clipboard. ````markdown - + Tux, the Linux mascot #### My charts @@ -310,7 +310,7 @@ Suppose a new Streamlit release includes a `st.my_chart` function that you want ```YAML - category: Streamlit Library / API Reference / Chart elements / st.my_chart - url: /library/api-reference/charts/st.my_chart + url: /develop/api-reference/charts/st.my_chart ``` 6. Save your changes and refresh the browser tab. If all went well, you should see a new entry in the Menu, a new card in the API Reference, and a new page for `st.my_chart`. diff --git a/components/navigation/navItem.js b/components/navigation/navItem.js index 119216a6f..91526e1b4 100644 --- a/components/navigation/navItem.js +++ b/components/navigation/navItem.js @@ -73,15 +73,9 @@ const NavItem = ({ page, slug, condensed, className }) => { if (page.url.startsWith("/")) { navItem = (
  • - {page.url === "/library" ? ( - - {navBox} - - ) : ( - - {navBox} - - )} + + {navBox} + {subNav}
  • ); diff --git a/components/summaryTiles.js b/components/summaryTiles.js index c09598c41..4b9633d8f 100644 --- a/components/summaryTiles.js +++ b/components/summaryTiles.js @@ -17,7 +17,7 @@ const SummaryTiles = () => { title="API reference" text="Learn about our APIs, with actionable explanations of specific functions and features." background="indigo-70" - link="/library/api-reference" + link="/develop/api-reference" /> + Understand the basics of app deployment. + Deploy your app on our free platform and join a community of developers who share their apps around the world. + Deploy your app in Snowflake to enjoy a role-based access controlled environment with all your data in one unified, global system. + Learn how to deploy your on a variety of platforms with our convenient collection of tutorials. + diff --git a/content/deploy/concepts/_index.md b/content/deploy/concepts/_index.md new file mode 100644 index 000000000..ac0b5722a --- /dev/null +++ b/content/deploy/concepts/_index.md @@ -0,0 +1,29 @@ +--- +title: Deployment concepts +slug: /deploy/concepts +--- + +# Deployment concepts + +Learn the fundamental concepts of app deployment. There are three main processes involved in deploying apps. + +- Install Python, Streamlit, and other dependencies in your deployment environment. +- Securely handle your secrets and private information. +- Remote start your app (`streamlit run`). + +If you're using Streamlit Community Cloud, we'll do most of the work for you! + + + Understand the basics of configuring your deployment environment. + Understand the basics of secret management. + diff --git a/content/deploy/concepts/dependencies.md b/content/deploy/concepts/dependencies.md new file mode 100644 index 000000000..09dcb11d5 --- /dev/null +++ b/content/deploy/concepts/dependencies.md @@ -0,0 +1,55 @@ +--- +title: Managing dependencies when deploying your app +slug: /deploy/concepts/dependencies +--- + +# Managing dependencies when deploying your app + +Before you began developing your app, you set up and configured your development environment by installing Python and Streamlit. When you deploy your app, you need to set up and configure your deploymnet environment in the same way. When you deploy your app to a cloud service, your app's [Python server](/develop/concepts/architecture/architecture#python-backend-server) will be running on a remote machine. This remote machine will not have access all the files and programs on your personal computer. + +All Streamlit apps have at least two dependencies: Python and Streamlit. Your app may have additional dependencies in the form of Python packages or software that must be installed to properly execute your script. If you are using a service like Streamlit Community Cloud which is designed for Streamlit apps, we'll take care of Python and Streamlit for you! + +## Install Python and other software + +If you are using Streamlit Community Cloud, Python is already installed. You can just pick the version in the deployment dialog. If you need to install Python yourself or you have other non-Python software to install, follow your platform's instructions to install additional software. You will commonly use a package management tool to do this. +For example, Streamlit Community Cloud uses Advanced Package Tool (`apt`) for Debian-based Linux systems. For more information about installing non-Python depencies on Streamlit Community Cloud, see [`apt-get` dependencies](/deploy/streamlit-community-cloud/deploy-your-app/app-dependencies#apt-get-dependencies). + +## Install Python packages + +Once you have Python installed in your deployment environment, you'll need to install all the necessary Python packages, including Streamlit! With each `import` of an installed package, you add a Python dependency to your script. You need to install those dependencies in your deployment environment through a Python package manager. + +If you are using Streamlit Community Cloud, you'll have the latest version of Streamlit and all of its dependencies installed by default. So, if you're making a simple app and don't need additional dependencies, you won't have to do anything at all! + +### `pip` and `requirements.txt` + +Since `pip` comes by default with Python, the most common way to configure your Python environment is with a `requirements.txt` file. Each line of a `requirements.txt` file is a package to `pip install`. You should _not_ include built-in Python libraries like `math` or `random` in your `requirements.txt` file. These are a part of Python and aren't installed separately. + +If you have a script like the following, you would only need to install Streamlit. No extra dependencies would be needed since `pandas` and `numpy` are installed as direct dependencies of `streamlit`. Similarly, `math` and `random` are built into Python. + +```python +import streamlit as st +import pandas as pd +import numpy as np +import math +import random + +st.write('Hi!') +``` + +However, it's a best practice accurately record pacakges you use, so the recommended `requirements.txt` file would be: + +```none +streamlit +pandas +numpy +``` + +If you needed to specify certain versions, another valid example would be: + +```none +streamlit==1.24.1 +pandas>2.0 +numpy<=1.25.1 +``` + +A `requirements.txt` file is commonly saved in the root of your repository or file directory. If you are using Streamlit Community Cloud, see [Add Python dependencies](/deploy/streamlit-community-cloud/deploy-your-app/app-dependencies#add-python-dependencies) for more information. Othwerwise, check your platform's documentation. diff --git a/content/deploy/concepts/secrets.md b/content/deploy/concepts/secrets.md new file mode 100644 index 000000000..db55a437e --- /dev/null +++ b/content/deploy/concepts/secrets.md @@ -0,0 +1,14 @@ +--- +title: Managing secrets when deploying your app +slug: /deploy/concepts/secrets +--- + +# Managing secrets when deploying your app + +If you are connecting to data sources or external services, you will likely be handling secret information like credentials or keys. Secret information should be stored and transmitted in a secure manner. When you deploy your app, ensure that you understand your platform's features and mechanisms for handling secrets so you can follow best practice. + +Avoid saving secrets directly in your code and keep `.gitignore` updated to prevent accidentally committing a local secret to your repository. For helpful reminders, see [Security reminders](/develop/concepts/connections/security-reminders). + +If you are using Streamlit Community Cloud, [Secrets management](/deploy/streamlit-community-cloud/deploy-your-app/secrets-management) allows you save environment variables and store secrets outside of your code. If you are using another platform designed for Streamlit, check if they have a built-in mechanism for working with `st.secrets` or securely uploading your `secrets.toml` file. + +For information about using `st.connection` with environment variables, see [Global secrets, managing multiple apps and multiple data stores](/develop/concepts/connections/connecting-to-data#global-secrets-managing-multiple-apps-and-multiple-data-stores). diff --git a/content/get-started/index.md b/content/get-started/_index.md similarity index 96% rename from content/get-started/index.md rename to content/get-started/_index.md index 2537a96b8..33427a6c6 100644 --- a/content/get-started/index.md +++ b/content/get-started/_index.md @@ -1,9 +1,9 @@ --- -title: Get started +title: Get started with Streamlit slug: /get-started --- -# Get started +# Get started with Streamlit This Get Started guide explains how Streamlit works, how to install Streamlit on your preferred operating system, and how to create your first Streamlit app! @@ -24,7 +24,7 @@ operating system, and how to create your first Streamlit app! walks you through creating apps using core features to fetch and cache data, draw charts, plot information on a map, and use interactive widgets to filter results. Learn the fundamental concepts of Streamlit. How is a Streamlit app structured? How does it run? How does it magically get your data on a webpage? @@ -101,11 +101,11 @@ Now run `streamlit run main_page.py` and view your shiny new multipage app! -Our documentation on [Multipage apps](/library/advanced-features/multipage-apps) teaches you how to add pages to your app, including how to define pages, structure and run multipage apps, and navigate between pages. Once you understand the basics, [create your first multipage app](/get-started/tutorials/create-a-multipage-app)! +Our documentation on [Multipage apps](/develop/concepts/multipage-apps) teaches you how to add pages to your app, including how to define pages, structure and run multipage apps, and navigate between pages. Once you understand the basics, [create your first multipage app](/get-started/tutorials/create-a-multipage-app)! ## Custom components -If you can't find the right component within the Streamlit library, try out custom components to extend Streamlit's built-in functionality. Explore and browse through popular, community-created components in the [Components gallery](https://streamlit.io/components). If you dabble in frontend development, you can build your own custom component with Streamlit's [components API](/library/components/components-api). +If you can't find the right component within the Streamlit library, try out custom components to extend Streamlit's built-in functionality. Explore and browse through popular, community-created components in the [Components gallery](https://streamlit.io/components). If you dabble in frontend development, you can build your own custom component with Streamlit's [components API](/develop/concepts/custom-components/intro). ## Static file serving @@ -118,8 +118,8 @@ your-project/ └── streamlit_app.py ``` -To learn more, read our guide on [Static file serving](/library/advanced-features/static-file-serving). +To learn more, read our guide on [Static file serving](/develop/concepts/configuration/static-file-serving). ## App testing -Good development hygeine includes testing your code. Automated testing allows you to write higher quality code, faster! Streamlit has a built-in testing framework that let's you build tests easily. Use your favorite testing framework to run your tests. We like [`pytest`](https://pypi.org/project/pytest/). When you test a Streamlit app, you simulate running the app, declare user input, and inspect the results. You can use GitHub workflows to automate your tests and get instant alerts about breaking changes. Learn more in our guide to [App testing](/library/advanced-features/app-testing). +Good development hygeine includes testing your code. Automated testing allows you to write higher quality code, faster! Streamlit has a built-in testing framework that let's you build tests easily. Use your favorite testing framework to run your tests. We like [`pytest`](https://pypi.org/project/pytest/). When you test a Streamlit app, you simulate running the app, declare user input, and inspect the results. You can use GitHub workflows to automate your tests and get instant alerts about breaking changes. Learn more in our guide to [App testing](/develop/concepts/app-testing). diff --git a/content/get-started/fundamentals/advanced-concepts.md b/content/get-started/fundamentals/advanced-concepts.md index d8c17cf8c..b1acdeb80 100644 --- a/content/get-started/fundamentals/advanced-concepts.md +++ b/content/get-started/fundamentals/advanced-concepts.md @@ -15,7 +15,7 @@ The basic idea behind caching is to store the results of expensive function call To cache a function in Streamlit, you need to apply a caching decorator to it. You have two choices: -- `st.cache_data` is the recommended way to cache computations that return data. Use `st.cache_data` when you use a function that returns a serializable data object (e.g. str, int, float, DataFrame, dict, list). **It creates a new copy of the data at each function call**, making it safe against [mutations and race conditions](/library/advanced-features/caching#mutation-and-concurrency-issues). The behavior of `st.cache_data` is what you want in most cases – so if you're unsure, start with `st.cache_data` and see if it works! +- `st.cache_data` is the recommended way to cache computations that return data. Use `st.cache_data` when you use a function that returns a serializable data object (e.g. str, int, float, DataFrame, dict, list). **It creates a new copy of the data at each function call**, making it safe against [mutations and race conditions](/develop/concepts/architecture/caching#mutation-and-concurrency-issues). The behavior of `st.cache_data` is what you want in most cases – so if you're unsure, start with `st.cache_data` and see if it works! - `st.cache_resource` is the recommended way to cache global resources like ML models or database connections. Use `st.cache_resource` when your function returns unserializable objects that you don’t want to load multiple times. **It returns the cached object itself**, which is shared across all reruns and sessions without copying or duplication. If you mutate an object that is cached using `st.cache_resource`, that mutation will exist across all reruns and sessions. Example: @@ -36,7 +36,7 @@ Before running the code within `long_running_function`, Streamlit checks its cac Streamlit's two caching decorators and their use cases. Use st.cache_data for anything you'd store in a database. Use st.cache_resource for anything you can't store in a database, like a connection to a database or a machine learning model. -For more information about the Streamlit caching decorators, their configuration parameters, and their limitations, see [Caching](/library/advanced-features/caching). +For more information about the Streamlit caching decorators, their configuration parameters, and their limitations, see [Caching](/develop/concepts/architecture/caching). ## Session State @@ -89,7 +89,7 @@ st.scatter_chart(st.session_state.df, x="x", y="y", color=color) If you are pulling the same data for all users, you'd likely cache a function that retrieves that data. On the other hand, if you pull data specific to a user, such as querying their personal information, you may want to save that in Session State. That way, the queried data is only available in that one session. -As mentioned in [Main concepts](/get-started/fundamentals/main-concepts#widgets), Session State is also related to widgets. Widgets are magical and handle statefulness quietly on their own. As an advanced feature however, you can manipulate the value of widgets within your code by assigning keys to them. Any key assigned to a widget becomes a key in Session State tied to the value of the widget. This can be used to manipulate the widget. After you finish understanding the basics of Streamlit, check out our guide on [Widget behavior](/library/advanced-features/widget-behavior) to dig in the details if you're interested. +As mentioned in [Basic concepts](/get-started/fundamentals/main-concepts#widgets), Session State is also related to widgets. Widgets are magical and handle statefulness quietly on their own. As an advanced feature however, you can manipulate the value of widgets within your code by assigning keys to them. Any key assigned to a widget becomes a key in Session State tied to the value of the widget. This can be used to manipulate the widget. After you finish understanding the basics of Streamlit, check out our guide on [Widget behavior](/develop/concepts/architecture/widget-behavior) to dig in the details if you're interested. ## Connections @@ -103,7 +103,7 @@ df = conn.query("select * from my_table") st.dataframe(df) ``` -Of course, you may be wondering where your username and password go. Streamlit has a convenient mechanism for [Secrets management](/library/advanced-features/secrets-management). For now, let's just see how `st.connection` works very nicely with secrets. In your local project directory, you can save a `.streamlit/secrets.toml` file. You save your secrets in the toml file and `st.connection` just uses them! For example, if you have an app file `streamlit_app.py` your project directory may look like this: +Of course, you may be wondering where your username and password go. Streamlit has a convenient mechanism for [Secrets management](/develop/concepts/connections/secrets-management). For now, let's just see how `st.connection` works very nicely with secrets. In your local project directory, you can save a `.streamlit/secrets.toml` file. You save your secrets in the toml file and `st.connection` just uses them! For example, if you have an app file `streamlit_app.py` your project directory may look like this: ```bash your-LOCAL-repository/ @@ -125,4 +125,4 @@ For the above SQL example, your `secrets.toml` file might look like the followin database="mydb" # Database name ``` -Since you don't want to commit your `secrets.toml` file to your repository, you'll need to learn how your host handles secrets when you're ready to publish your app. Each host platform may have a different way for you to pass your secrets. If you use Streamlit Community Cloud for example, each deployed app has a settings menu where you can load your secrets. After you've written an app and are ready to deploy, you can read all about how to [Deploy your app](/streamlit-community-cloud/deploy-your-app) on Community Cloud. +Since you don't want to commit your `secrets.toml` file to your repository, you'll need to learn how your host handles secrets when you're ready to publish your app. Each host platform may have a different way for you to pass your secrets. If you use Streamlit Community Cloud for example, each deployed app has a settings menu where you can load your secrets. After you've written an app and are ready to deploy, you can read all about how to [Deploy your app](/deploy/streamlit-community-cloud/deploy-your-app) on Community Cloud. diff --git a/content/get-started/fundamentals/main-concepts.md b/content/get-started/fundamentals/main-concepts.md index 9a90fda92..8fd198453 100644 --- a/content/get-started/fundamentals/main-concepts.md +++ b/content/get-started/fundamentals/main-concepts.md @@ -1,9 +1,9 @@ --- -title: Main concepts of Streamlit +title: Basic concepts of Streamlit slug: /get-started/fundamentals/main-concepts --- -# Main concepts of Streamlit +# Basic concepts of Streamlit Working with Streamlit is simple. First you sprinkle a few Streamlit commands into a normal Python script, then you run it with `streamlit run`: @@ -17,9 +17,9 @@ spin up and your app will open in a new tab in your default web browser. The app is your canvas, where you'll draw charts, text, widgets, tables, and more. What gets drawn in the app is up to you. For example -[`st.text`](/library/api-reference/text/st.text) writes raw text to your app, and -[`st.line_chart`](/library/api-reference/charts/st.line_chart) draws — you guessed it — a -line chart. Refer to our [API documentation](/library/api-reference) to see all commands that +[`st.text`](/develop/api-reference/text/st.text) writes raw text to your app, and +[`st.line_chart`](/develop/api-reference/charts/st.line_chart) draws — you guessed it — a +line chart. Refer to our [API documentation](/develop/api-reference) to see all commands that are available to you. @@ -73,7 +73,7 @@ time. Give it a try! As of Streamlit version 1.10.0 and higher, Streamlit apps cannot be run from the root directory of Linux distributions. If you try to run a Streamlit app from the root directory, Streamlit will throw a `FileNotFoundError: [Errno 2] No such file or directory` error. For more information, see GitHub issue [#5239](https://github.com/streamlit/streamlit/issues/5239). -If you are using Streamlit version 1.10.0 or higher, your main script should live in a directory other than the root directory. When using Docker, you can use the `WORKDIR` command to specify the directory where your main script lives. For an example of how to do this, read [Create a Dockerfile](/knowledge-base/tutorials/deploy/docker#create-a-dockerfile). +If you are using Streamlit version 1.10.0 or higher, your main script should live in a directory other than the root directory. When using Docker, you can use the `WORKDIR` command to specify the directory where your main script lives. For an example of how to do this, read [Create a Dockerfile](/deploy/tutorials/docker#create-a-dockerfile). ## Data flow @@ -89,7 +89,7 @@ This can happen in two situations: - Whenever a user interacts with widgets in the app. For example, when dragging a slider, entering text in an input box, or clicking a button. -Whenever a callback is passed to a widget via the `on_change` (or `on_click`) parameter, the callback will always run before the rest of your script. For details on the Callbacks API, please refer to our [Session State API Reference Guide](/library/api-reference/session-state#use-callbacks-to-update-session-state). +Whenever a callback is passed to a widget via the `on_change` (or `on_click`) parameter, the callback will always run before the rest of your script. For details on the Callbacks API, please refer to our [Session State API Reference Guide](/develop/api-reference/caching-and-state/st.session_state#use-callbacks-to-update-session-state). And to make all of this fast and seamless, Streamlit does some heavy lifting for you behind the scenes. A big player in this story is the @@ -101,15 +101,15 @@ page. There are a few ways to display data (tables, arrays, data frames) in Streamlit apps. [Below](#use-magic), you will be introduced to _magic_ -and [`st.write()`](/library/api-reference/write-magic/st.write), which can be used to write +and [`st.write()`](/develop/api-reference/write-magic/st.write), which can be used to write anything from text to tables. After that, let's take a look at methods designed specifically for visualizing data. ### Use magic You can also write to your app without calling any Streamlit methods. -Streamlit supports "[magic commands](/library/api-reference/write-magic/magic)," which means you don't have to use -[`st.write()`](/library/api-reference/write-magic/st.write) at all! To see this in action try this snippet: +Streamlit supports "[magic commands](/develop/api-reference/write-magic/magic)," which means you don't have to use +[`st.write()`](/develop/api-reference/write-magic/st.write) at all! To see this in action try this snippet: ```python """ @@ -129,14 +129,14 @@ df Any time that Streamlit sees a variable or a literal value on its own line, it automatically writes that to your app using -[`st.write()`](/library/api-reference/write-magic/st.write). For more information, refer to the -documentation on [magic commands](/library/api-reference/write-magic/magic). +[`st.write()`](/develop/api-reference/write-magic/st.write). For more information, refer to the +documentation on [magic commands](/develop/api-reference/write-magic/magic). ### Write a data frame -Along with [magic commands](/library/api-reference/write-magic/magic), -[`st.write()`](/library/api-reference/write-magic/st.write) is Streamlit's "Swiss Army knife". You -can pass almost anything to [`st.write()`](/library/api-reference/write-magic/st.write): +Along with [magic commands](/develop/api-reference/write-magic/magic), +[`st.write()`](/develop/api-reference/write-magic/st.write) is Streamlit's "Swiss Army knife". You +can pass almost anything to [`st.write()`](/develop/api-reference/write-magic/st.write): text, data, Matplotlib figures, Altair charts, and more. Don't worry, Streamlit will figure it out and render things the right way. @@ -152,14 +152,14 @@ st.write(pd.DataFrame({ ``` There are other data specific functions like -[`st.dataframe()`](/library/api-reference/data/st.dataframe) and -[`st.table()`](/library/api-reference/data/st.table) that you can also use for displaying +[`st.dataframe()`](/develop/api-reference/data/st.dataframe) and +[`st.table()`](/develop/api-reference/data/st.table) that you can also use for displaying data. Let's understand when to use these features and how to add colors and styling to your data frames. You might be asking yourself, "why wouldn't I always use `st.write()`?" There are a few reasons: -1. _Magic_ and [`st.write()`](/library/api-reference/write-magic/st.write) inspect the type of +1. _Magic_ and [`st.write()`](/develop/api-reference/write-magic/st.write) inspect the type of data that you've passed in, and then decide how to best render it in the app. Sometimes you want to draw it another way. For example, instead of drawing a dataframe as an interactive table, you may want to draw it as a @@ -171,7 +171,7 @@ a few reasons: For example, let's create a data frame and change its formatting with a Pandas `Styler` object. In this example, you'll use Numpy to generate a random sample, -and the [`st.dataframe()`](/library/api-reference/data/st.dataframe) method to draw an +and the [`st.dataframe()`](/develop/api-reference/data/st.dataframe) method to draw an interactive table. @@ -205,7 +205,7 @@ st.dataframe(dataframe.style.highlight_max(axis=0)) ``` Streamlit also has a method for static table generation: -[`st.table()`](/library/api-reference/data/st.table). +[`st.table()`](/develop/api-reference/data/st.table). ```python import streamlit as st @@ -221,13 +221,13 @@ st.table(dataframe) ### Draw charts and maps Streamlit supports several popular data charting libraries like [Matplotlib, -Altair, deck.gl, and more](/library/api-reference#chart-elements). In this section, you'll +Altair, deck.gl, and more](/develop/api-reference#chart-elements). In this section, you'll add a bar chart, line chart, and a map to your app. ### Draw a line chart You can easily add a line chart to your app with -[`st.line_chart()`](/library/api-reference/charts/st.line_chart). We'll generate a random +[`st.line_chart()`](/develop/api-reference/charts/st.line_chart). We'll generate a random sample using Numpy and then chart it. ```python @@ -244,7 +244,7 @@ st.line_chart(chart_data) ### Plot a map -With [`st.map()`](/library/api-reference/charts/st.map) you can display data points on a map. +With [`st.map()`](/develop/api-reference/charts/st.map) you can display data points on a map. Let's use Numpy to generate some sample data and plot it on a map of San Francisco. @@ -263,9 +263,9 @@ st.map(map_data) ## Widgets When you've got the data or model into the state that you want to explore, you -can add in widgets like [`st.slider()`](/library/api-reference/widgets/st.slider), -[`st.button()`](/library/api-reference/widgets/st.button) or -[`st.selectbox()`](/library/api-reference/widgets/st.selectbox). It's really straightforward +can add in widgets like [`st.slider()`](/develop/api-reference/widgets/st.slider), +[`st.button()`](/develop/api-reference/widgets/st.button) or +[`st.selectbox()`](/develop/api-reference/widgets/st.selectbox). It's really straightforward — treat widgets as variables: ```python @@ -293,12 +293,12 @@ st.text_input("Your name", key="name") st.session_state.name ``` -Every widget with a key is automatically added to Session State. For more information about Session State, its association with widget state, and its limitations, see [Session State API Reference Guide](/library/api-reference/session-state). +Every widget with a key is automatically added to Session State. For more information about Session State, its association with widget state, and its limitations, see [Session State API Reference Guide](/develop/api-reference/caching-and-state/st.session_state). ### Use checkboxes to show/hide data One use case for checkboxes is to hide or show a specific chart or section in -an app. [`st.checkbox()`](/library/api-reference/widgets/st.checkbox) takes a single argument, +an app. [`st.checkbox()`](/develop/api-reference/widgets/st.checkbox) takes a single argument, which is the widget label. In this sample, the checkbox is used to toggle a conditional statement. @@ -317,7 +317,7 @@ if st.checkbox('Show dataframe'): ### Use a selectbox for options -Use [`st.selectbox`](/library/api-reference/widgets/st.selectbox) to choose from a series. You +Use [`st.selectbox`](/develop/api-reference/widgets/st.selectbox) to choose from a series. You can write in the options you want, or pass through an array or data frame column. @@ -342,8 +342,8 @@ option = st.selectbox( ## Layout Streamlit makes it easy to organize your widgets in a left panel sidebar with -[`st.sidebar`](/library/api-reference/layout/st.sidebar). Each element that's passed to -[`st.sidebar`](/library/api-reference/layout/st.sidebar) is pinned to the left, allowing +[`st.sidebar`](/develop/api-reference/layout/st.sidebar). Each element that's passed to +[`st.sidebar`](/develop/api-reference/layout/st.sidebar) is pinned to the left, allowing users to focus on the content in your app while still having access to UI controls. @@ -368,8 +368,8 @@ add_slider = st.sidebar.slider( ``` Beyond the sidebar, Streamlit offers several other ways to control the layout -of your app. [`st.columns`](/library/api-reference/layout/st.columns) lets you place widgets side-by-side, and -[`st.expander`](/library/api-reference/layout/st.expander) lets you conserve space by hiding away large content. +of your app. [`st.columns`](/develop/api-reference/layout/st.columns) lets you place widgets side-by-side, and +[`st.expander`](/develop/api-reference/layout/st.expander) lets you conserve space by hiding away large content. ```python import streamlit as st @@ -396,7 +396,7 @@ or layout options. Rest assured, though, we're currently working on adding suppo ### Show progress When adding long running computations to an app, you can use -[`st.progress()`](/library/api-reference/status/st.progress) to display status in real time. +[`st.progress()`](/develop/api-reference/status/st.progress) to display status in real time. First, let's import time. We're going to use the `time.sleep()` method to simulate a long running computation: diff --git a/content/get-started/fundamentals/tutorials/index.md b/content/get-started/fundamentals/tutorials/_index.md similarity index 63% rename from content/get-started/fundamentals/tutorials/index.md rename to content/get-started/fundamentals/tutorials/_index.md index b2073a3ea..0cd8adf1e 100644 --- a/content/get-started/fundamentals/tutorials/index.md +++ b/content/get-started/fundamentals/tutorials/_index.md @@ -1,11 +1,11 @@ --- -title: Tutorials +title: First steps building Streamlit apps slug: /get-started/tutorials --- -# Tutorials +# First steps building Streamlit apps -If you've just read through our [Main concepts](/get-started/fundamentals/main-concepts) and want to get your hands on Streamlit. Check out these tutorials. Make sure you have [installed Streamlit](/get-started/installation) so you can execute the code yourself. +If you've just read through our [Basic concepts](/get-started/fundamentals/main-concepts) and want to get your hands on Streamlit. Check out these tutorials. Make sure you have [installed Streamlit](/get-started/installation) so you can execute the code yourself. Whenever you have a long-running computation in your code, consider -refactoring it so you can use `@st.cache_data`, if possible. Please read [Caching](/library/advanced-features/caching) for more details. +refactoring it so you can use `@st.cache_data`, if possible. Please read [Caching](/develop/concepts/architecture/caching) for more details. @@ -196,15 +196,15 @@ st.subheader('Raw data') st.write(data) ``` -In the [Main concepts](/get-started/fundamentals/main-concepts) guide you learned that -[`st.write`](/library/api-reference/write-magic/st.write) will render almost anything you pass +In the [Basic concepts](/get-started/fundamentals/main-concepts) guide you learned that +[`st.write`](/develop/api-reference/write-magic/st.write) will render almost anything you pass to it. In this case, you're passing in a dataframe and it's rendering as an interactive table. -[`st.write`](/library/api-reference/write-magic/st.write) tries to do the right thing based on +[`st.write`](/develop/api-reference/write-magic/st.write) tries to do the right thing based on the data type of the input. If it isn't doing what you expect you can use a -specialized command like [`st.dataframe`](/library/api-reference/data/st.dataframe) -instead. For a full list, see [API reference](/library/api-reference). +specialized command like [`st.dataframe`](/develop/api-reference/data/st.dataframe) +instead. For a full list, see [API reference](/develop/api-reference). ## Draw a histogram @@ -227,7 +227,7 @@ Uber's busiest hours are in New York City. ``` 3. Now, let's use Streamlit's - [`st.bar_chart()`](/library/api-reference/charts/st.bar_chart) method to draw this + [`st.bar_chart()`](/develop/api-reference/charts/st.bar_chart) method to draw this histogram. ```python @@ -240,7 +240,7 @@ Uber's busiest hours are in New York City. To draw this diagram we used Streamlit's native `bar_chart()` method, but it's important to know that Streamlit supports more complex charting libraries like Altair, Bokeh, Plotly, Matplotlib and more. For a full list, see -[supported charting libraries](/library/api-reference/charts). +[supported charting libraries](/develop/api-reference/charts). ## Plot data on a map @@ -249,7 +249,7 @@ times are for pickups, but what if we wanted to figure out where pickups were concentrated throughout the city. While you could use a bar chart to show this data, it wouldn't be easy to interpret unless you were intimately familiar with latitudinal and longitudinal coordinates in the city. To show pickup -concentration, let's use Streamlit [`st.map()`](/library/api-reference/charts/st.map) +concentration, let's use Streamlit [`st.map()`](/develop/api-reference/charts/st.map) function to overlay the data on a map of New York City. 1. Add a subheader for the section: @@ -289,9 +289,9 @@ at 17:00. 3. You should see the data update instantly. -To draw this map we used the [`st.map`](/library/api-reference/charts/st.map) function that's built into Streamlit, but +To draw this map we used the [`st.map`](/develop/api-reference/charts/st.map) function that's built into Streamlit, but if you'd like to visualize complex map data, we encourage you to take a look at -the [`st.pydeck_chart`](/library/api-reference/charts/st.pydeck_chart). +the [`st.pydeck_chart`](/develop/api-reference/charts/st.pydeck_chart). ## Filter results with a slider @@ -311,7 +311,7 @@ slider to the app with the `st.slider()` method. ## Use a button to toggle data Sliders are just one way to dynamically change the composition of your app. -Let's use the [`st.checkbox`](/library/api-reference/widgets/st.checkbox) function to add a +Let's use the [`st.checkbox`](/develop/api-reference/widgets/st.checkbox) function to add a checkbox to your app. We'll use this checkbox to show/hide the raw data table at the top of your app. @@ -330,7 +330,7 @@ table at the top of your app. st.write(data) ``` -We're sure you've got your own ideas. When you're done with this tutorial, check out all the widgets that Streamlit exposes in our [API Reference](/library/api-reference). +We're sure you've got your own ideas. When you're done with this tutorial, check out all the widgets that Streamlit exposes in our [API Reference](/develop/api-reference). ## Let's put it all together @@ -392,7 +392,7 @@ It works in 3 simple steps: 2. Sign into [share.streamlit.io](https://share.streamlit.io) 3. Click 'Deploy an app' and then paste in your GitHub URL -That's it! 🎈 You now have a publicly deployed app that you can share with the world. Click to learn more about [how to use Streamlit Community Cloud](/streamlit-community-cloud). +That's it! 🎈 You now have a publicly deployed app that you can share with the world. Click to learn more about [how to use Streamlit Community Cloud](/deploy/streamlit-community-cloud). ## Get help @@ -403,5 +403,5 @@ run into difficulties here are a few things you can do. - Quick help from command line with `streamlit help` - Go through our [Knowledge Base](/knowledge-base) for tips, step-by-step tutorials, and articles that answer your questions about creating and deploying Streamlit apps. - Read more documentation! Check out: - - [Advanced features](/library/advanced-features) for things like caching, theming, and adding statefulness to apps. - - [API reference](/library/api-reference/) for examples of every Streamlit command. + - [Concepts](/develop/concepts) for things like caching, theming, and adding statefulness to apps. + - [API reference](/develop/api-reference/) for examples of every Streamlit command. diff --git a/content/get-started/installation/index.md b/content/get-started/installation/_index.md similarity index 93% rename from content/get-started/installation/index.md rename to content/get-started/installation/_index.md index 0fe9e9ae4..ef8123c83 100644 --- a/content/get-started/installation/index.md +++ b/content/get-started/installation/_index.md @@ -1,9 +1,9 @@ --- -title: Installation +title: Install Streamlit slug: /get-started/installation --- -# Installation +# Install Streamlit There are multiple ways to set up your development environment and install Streamlit. Read below to understand these options. Developing locally with Python installed on your own computer is the most @@ -20,7 +20,7 @@ common scenario. ```bash streamlit hello ``` -4. Jump to our [Main concepts](/get-started/fundamentals/main-concepts). +4. Jump to our [Basic concepts](/get-started/fundamentals/main-concepts). ## Installation steps for the rest of us diff --git a/content/get-started/installation/anaconda-distribution.md b/content/get-started/installation/anaconda-distribution.md index 73c1aae95..ea12976c2 100644 --- a/content/get-started/installation/anaconda-distribution.md +++ b/content/get-started/installation/anaconda-distribution.md @@ -146,4 +146,4 @@ This page walks you through installing Streamlit locally using Anaconda Distribu ## What's next? -Read about our [Main concepts](/get-started/fundamentals/main-concepts) and try out more commands in your app. +Read about our [Basic concepts](/get-started/fundamentals/main-concepts) and try out more commands in your app. diff --git a/content/get-started/installation/cloud-quickstart.md b/content/get-started/installation/cloud-quickstart.md index a8554db65..802311950 100644 --- a/content/get-started/installation/cloud-quickstart.md +++ b/content/get-started/installation/cloud-quickstart.md @@ -7,7 +7,7 @@ slug: /get-started/installation/community-cloud To use GitHub codespaces for Streamlit development, a properly configured `devcontainer.json` file is needed to set up the environment. Fortunately, Community Cloud is here to help! Although Streamlit Community Cloud is primarily used to deploy and share apps with the rest of the world, we've build in some handy features to make it easy to use GitHub Codespaces. This guide explains how to create a Community Cloud account and use an automated workflow to get you into a GitHub codespace and live-editing a Streamlit app. The automated workflow will fork our Streamlit Hello app to your GitHub account, deploy it, then open up a codespace for you to start editing. All this happens right in your browser, no installation required. -You will be signing in to your Google and GitHub accounts during this process. If you do not already have these accounts, you can create them before you begin. If you do not want to use a Google account, you can [create your account with any email](/streamlit-community-cloud/get-started/create-your-account#primary-identity-option-2-email). +You will be signing in to your Google and GitHub accounts during this process. If you do not already have these accounts, you can create them before you begin. If you do not want to use a Google account, you can [create your account with any email](/deploy/streamlit-community-cloud/get-started/create-your-account#primary-identity-option-2-email). ## Sign up for Streamlit Community Cloud @@ -129,7 +129,7 @@ When you are done, remember to stop your codespace on GitHub to avoid any undesi -21. Congratulations! You just deployed an app to Streamlit Community Cloud. 🎉 Head back to your workspace at share.streamlit.io/ and [deploy another Streamlit app](/streamlit-community-cloud/deploy-your-app). +21. Congratulations! You just deployed an app to Streamlit Community Cloud. 🎉 Head back to your workspace at share.streamlit.io/ and [deploy another Streamlit app](/deploy/streamlit-community-cloud/deploy-your-app).
    See your deployed Streamlit app diff --git a/content/get-started/installation/command-line.md b/content/get-started/installation/command-line.md index 01ff3cf52..c6dfdbb13 100644 --- a/content/get-started/installation/command-line.md +++ b/content/get-started/installation/command-line.md @@ -148,4 +148,4 @@ deactivate ## What's next? -Read about our [Main concepts](/get-started/fundamentals/main-concepts) to understand Streamlit's dataflow model. +Read about our [Basic concepts](/get-started/fundamentals/main-concepts) to understand Streamlit's dataflow model. diff --git a/content/get-started/installation/sis.md b/content/get-started/installation/sis.md index d63b172cc..7eb7aaa22 100644 --- a/content/get-started/installation/sis.md +++ b/content/get-started/installation/sis.md @@ -129,6 +129,6 @@ All you need is an email address! Everything else happens in your 30-day trial a ## What's next? -Read about our [Main concepts](/get-started/fundamentals/main-concepts) and try out more commands in your app. To create more apps in your account, you can proceed from [Create a "Hello World" Streamlit app](#create-a-hello-world-streamlit-app). The warehouse and database setup do not need to be repeated. +Read about our [Basic concepts](/get-started/fundamentals/main-concepts) and try out more commands in your app. To create more apps in your account, you can proceed from [Create a "Hello World" Streamlit app](#create-a-hello-world-streamlit-app). The warehouse and database setup do not need to be repeated. For more information about creating and managing Streamlit in Snowflake apps, check out the [Snowflake docs](https://docs.snowflake.com/en/developer-guide/streamlit/about-streamlit). diff --git a/content/index.md b/content/index.md index 259e991dc..862893dfd 100644 --- a/content/index.md +++ b/content/index.md @@ -12,7 +12,7 @@ features: fugit, sed quia. color: orange-70 icon: dvr - url: /library/api-reference + url: /develop/api-reference image: "" - title: Topic guides body: Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut diff --git a/content/kb/index.md b/content/kb/_index.md similarity index 65% rename from content/kb/index.md rename to content/kb/_index.md index 46b63b9ff..822337496 100644 --- a/content/kb/index.md +++ b/content/kb/_index.md @@ -10,22 +10,10 @@ The knowledge base is a self-serve library of tips, step-by-step tutorials, and Our tutorials include step-by-step examples of building different types of apps in Streamlit. - Here are some frequently asked questions about using Streamlit. - Here are some questions we've received about Streamlit Components. @@ -17,7 +17,7 @@ While this technique adds some level of security, it is **NOT** comparable to pr ## Option 1: One global password for all users -This is the easiest option! Your app will ask for a password that's shared between all users. It will be stored in the app secrets using [Secrets management](/streamlit-community-cloud/deploy-your-app/secrets-management). If you want to change this password or revoke a user's access, you will need to change it for everyone. If you want to have one password per user instead, jump to [Option 2 below](/knowledge-base/deploy/authentication-without-sso#option-2-individual-password-for-each-user). +This is the easiest option! Your app will ask for a password that's shared between all users. It will be stored in the app secrets using [Secrets management](/deploy/streamlit-community-cloud/deploy-your-app/secrets-management). If you want to change this password or revoke a user's access, you will need to change it for everyone. If you want to have one password per user instead, jump to [Option 2 below](/knowledge-base/deploy/authentication-without-sso#option-2-individual-password-for-each-user). ### Step 1: Add the password to your local app secrets @@ -37,7 +37,7 @@ Be sure to add this file to your `.gitignore` so you don't commit your secrets! ### Step 2: Copy your app secrets to the cloud -As the `secrets.toml` file above is not committed to GitHub, you need to pass its content to your deployed app (on Streamlit Community Cloud) separately. Go to the [app dashboard](https://share.streamlit.io/) and in the app's dropdown menu, click on **Edit Secrets**. Copy the content of `secrets.toml` into the text area. More information is available at [Secrets management](/streamlit-community-cloud/deploy-your-app/secrets-management). +As the `secrets.toml` file above is not committed to GitHub, you need to pass its content to your deployed app (on Streamlit Community Cloud) separately. Go to the [app dashboard](https://share.streamlit.io/) and in the app's dropdown menu, click on **Edit Secrets**. Copy the content of `secrets.toml` into the text area. More information is available at [Secrets management](/deploy/streamlit-community-cloud/deploy-your-app/secrets-management). ![Secrets manager screenshot](/images/databases/edit-secrets.png) @@ -90,7 +90,7 @@ If everything worked out, your app should look like this: ## Option 2: Individual password for each user -This option allows you to set a username and password for each user of your app. Like in [Option 1](#option-1-one-global-password-for-all-users), both values will be stored in the app secrets using [Secrets management](/streamlit-community-cloud/deploy-your-app/secrets-management). +This option allows you to set a username and password for each user of your app. Like in [Option 1](#option-1-one-global-password-for-all-users), both values will be stored in the app secrets using [Secrets management](/deploy/streamlit-community-cloud/deploy-your-app/secrets-management). ### Step 1: Add usernames & passwords to your local app secrets @@ -111,11 +111,11 @@ Be sure to add this file to your `.gitignore` so you don't commit your secrets! -Alternatively, you could set up and manage usernames & passwords via a spreadsheet or database. To use secrets to securely connect to Google Sheets, AWS, and other data providers, read our tutorials on how to [Connect Streamlit to data sources](/knowledge-base/tutorials/databases). +Alternatively, you could set up and manage usernames & passwords via a spreadsheet or database. To use secrets to securely connect to Google Sheets, AWS, and other data providers, read our tutorials on how to [Connect Streamlit to data sources](/develop/tutorials/databases). ### Step 2: Copy your app secrets to the cloud -As the `secrets.toml` file above is not committed to GitHub, you need to pass its content to your deployed app (on Streamlit Community Cloud) separately. Go to the [app dashboard](https://share.streamlit.io/) and in the app's dropdown menu, click on **Edit Secrets**. Copy the content of `secrets.toml` into the text area. More information is available at [Secrets management](/streamlit-community-cloud/deploy-your-app/secrets-management). +As the `secrets.toml` file above is not committed to GitHub, you need to pass its content to your deployed app (on Streamlit Community Cloud) separately. Go to the [app dashboard](https://share.streamlit.io/) and in the app's dropdown menu, click on **Edit Secrets**. Copy the content of `secrets.toml` into the text area. More information is available at [Secrets management](/deploy/streamlit-community-cloud/deploy-your-app/secrets-management). ![Secrets manager screenshot](/images/databases/edit-secrets.png) diff --git a/content/kb/deployments/huh-this-is-isnt-supposed-to-happen-message-after-trying-to-log-in.md b/content/kb/deployments/huh-this-is-isnt-supposed-to-happen-message-after-trying-to-log-in.md index 441883b1e..418aa507a 100644 --- a/content/kb/deployments/huh-this-is-isnt-supposed-to-happen-message-after-trying-to-log-in.md +++ b/content/kb/deployments/huh-this-is-isnt-supposed-to-happen-message-after-trying-to-log-in.md @@ -20,5 +20,5 @@ This message usually indicates that our system has linked your GitHub username w No worries – all you have to do is: 1. Log out of Streamlit Community Cloud completely (via both your email and GitHub accounts). -2. Log in first with your email account (you can do so via either ["Continue with Google"](/streamlit-community-cloud/manage-your-account/sign-in-sign-out#sign-in-with-google) or ["Continue with email"](/knowledge-base/deploy/sign-in-without-sso)). -3. Log in with your [GitHub account](/streamlit-community-cloud/manage-your-account/sign-in-sign-out#sign-in-with-email). +2. Log in first with your email account (you can do so via either ["Continue with Google"](/deploy/streamlit-community-cloud/manage-your-account/sign-in-sign-out#sign-in-with-google) or ["Continue with email"](/knowledge-base/deploy/sign-in-without-sso)). +3. Log in with your [GitHub account](/deploy/streamlit-community-cloud/manage-your-account/sign-in-sign-out#sign-in-with-email). diff --git a/content/kb/deployments/increase-upload-limit-cloud.md b/content/kb/deployments/increase-upload-limit-cloud.md index bf0ea4737..0b8349845 100644 --- a/content/kb/deployments/increase-upload-limit-cloud.md +++ b/content/kb/deployments/increase-upload-limit-cloud.md @@ -7,9 +7,9 @@ slug: /knowledge-base/deploy/increase-file-uploader-limit-streamlit-cloud ## Overview -By default, files uploaded using [`st.file_uploader()`](/library/api-reference/widgets/st.file_uploader) are limited to 200MB. You can configure this using the `server.maxUploadSize` config option. +By default, files uploaded using [`st.file_uploader()`](/develop/api-reference/widgets/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](/library/advanced-features/configuration#set-configuration-options): +Streamlit provides [four different ways to set configuration options](/develop/concepts/configuration#set-configuration-options): 1. In a **global config file** at `~/.streamlit/config.toml` for macOS/Linux or `%userprofile%/.streamlit/config.toml` for Windows: ```toml @@ -26,7 +26,7 @@ Streamlit provides [four different ways to set configuration options](/library/a streamlit run your_script.py --server.maxUploadSize 200 ``` -Which of the four options should you choose for an app deployed to [Streamlit Community Cloud](/streamlit-community-cloud)? 🤔 +Which of the four options should you choose for an app deployed to [Streamlit Community Cloud](/deploy/streamlit-community-cloud)? 🤔 ## Solution @@ -42,5 +42,5 @@ maxUploadSize = 400 ## Relevant resources - [Streamlit drag and drop capping at 200MB, need workaround](https://discuss.streamlit.io/t/streamlit-drag-and-drop-capping-at-200mb-need-workaround/19803/2) -- [File uploader widget API](/library/api-reference/widgets/st.file_uploader) -- [How to set Streamlit configuration options](/library/advanced-features/configuration#set-configuration-options) +- [File uploader widget API](/develop/api-reference/widgets/st.file_uploader) +- [How to set Streamlit configuration options](/develop/concepts/configuration#set-configuration-options) diff --git a/content/kb/deployments/invoking-python-subprocess-deployed-streamlit-app.md b/content/kb/deployments/invoking-python-subprocess-deployed-streamlit-app.md index 299536654..0b86ecf36 100644 --- a/content/kb/deployments/invoking-python-subprocess-deployed-streamlit-app.md +++ b/content/kb/deployments/invoking-python-subprocess-deployed-streamlit-app.md @@ -23,7 +23,7 @@ subprocess.run(["python", "script.py"]) When you run the above code block, you will get the version of Python that is on the system path—not necessarily the Python executable installed in the virtual environment that the Streamlit code is running under. -The solution is to detect the Python executable directly with [`sys.executable`](https://docs.python.org/3/library/sys.html#sys.executable): +The solution is to detect the Python executable directly with [`sys.executable`](https://docs.python.org/3/develop/sys.html#sys.executable): ```python # streamlit_app.py @@ -34,10 +34,10 @@ import sys subprocess.run([f"{sys.executable}", "script.py"]) ``` -This ensures that `script.py` is running under the same Python executable as your Streamlit code—where your [Python dependencies](/streamlit-community-cloud/deploy-your-app/app-dependencies#add-python-dependencies) are installed. +This ensures that `script.py` is running under the same Python executable as your Streamlit code—where your [Python dependencies](/deploy/streamlit-community-cloud/deploy-your-app/app-dependencies#add-python-dependencies) are installed. ### Relevant links - https://stackoverflow.com/questions/69947867/run-portion-of-python-code-in-parallel-from-a-streamlit-app/69948545#69948545 - https://discuss.streamlit.io/t/modulenotfounderror-no-module-named-cv2-streamlit/18319/3?u=snehankekre -- https://docs.python.org/3/library/sys.html#sys.executable +- https://docs.python.org/3/develop/sys.html#sys.executable diff --git a/content/kb/deployments/resource-limits.md b/content/kb/deployments/resource-limits.md index d5cd2e5a0..30fece023 100644 --- a/content/kb/deployments/resource-limits.md +++ b/content/kb/deployments/resource-limits.md @@ -5,7 +5,7 @@ slug: /knowledge-base/deploy/resource-limits # Argh. This app has gone over its resource limits -Sorry! It means you've hit the [resource limits](/streamlit-community-cloud/manage-your-app#app-resources-and-limits) of your [Streamlit Community Cloud](https://streamlit.io/cloud) account. +Sorry! It means you've hit the [resource limits](/deploy/streamlit-community-cloud/manage-your-app#app-resources-and-limits) of your [Streamlit Community Cloud](https://streamlit.io/cloud) account. There are a few things you can change in your app to make it less resource-hungry: @@ -15,7 +15,7 @@ There are a few things you can change in your app to make it less resource-hungr - Move big datasets to a database - Profile your app's memory usage -Check out our [blog post](https://blog.streamlit.io/common-app-problems-resource-limits/) on ["Common app problems: Resource limits"](https://blog.streamlit.io/common-app-problems-resource-limits/) for more in-depth tips prevent your app from hitting the [resource limits](/streamlit-community-cloud/manage-your-app#app-resources-and-limits) of the Streamlit Community Cloud. +Check out our [blog post](https://blog.streamlit.io/common-app-problems-resource-limits/) on ["Common app problems: Resource limits"](https://blog.streamlit.io/common-app-problems-resource-limits/) for more in-depth tips prevent your app from hitting the [resource limits](/deploy/streamlit-community-cloud/manage-your-app#app-resources-and-limits) of the Streamlit Community Cloud. Related forum posts: diff --git a/content/kb/deployments/upgrade-streamlit-version.md b/content/kb/deployments/upgrade-streamlit-version.md index 814ea8b73..38d7a3e89 100644 --- a/content/kb/deployments/upgrade-streamlit-version.md +++ b/content/kb/deployments/upgrade-streamlit-version.md @@ -5,7 +5,7 @@ slug: /knowledge-base/deploy/upgrade-streamlit-version-on-streamlit-cloud # Upgrade the Streamlit version of your app on Streamlit Community Cloud -Want to use a cool new Streamlit feature but your app on Streamlit Community Cloud is running an old version of the Streamlit library? If that's you, don't worry! All you need to do is upgrade your app's Streamlit version. Here are five ways to do this, based on how your [app manages dependencies](/streamlit-community-cloud/deploy-your-app/app-dependencies): +Want to use a cool new Streamlit feature but your app on Streamlit Community Cloud is running an old version of the Streamlit library? If that's you, don't worry! All you need to do is upgrade your app's Streamlit version. Here are five ways to do this, based on how your [app manages dependencies](/deploy/streamlit-community-cloud/deploy-your-app/app-dependencies): ## No dependency file diff --git a/content/kb/tutorials/_index.md b/content/kb/tutorials/_index.md new file mode 100644 index 000000000..86b68fd84 --- /dev/null +++ b/content/kb/tutorials/_index.md @@ -0,0 +1,38 @@ +--- +title: Tutorials +slug: /develop/tutorials +--- + +# Tutorials + +Our tutorials include step-by-step examples of building different types of apps in Streamlit. + + + + + +
    Connect to data sources
    + +Connect to popular datasources. + +
    + + + +
    Create multipage apps
    + +Create multipage apps, navigation, and flows. + +
    + + + +
    Chat apps and LLMs
    + +Work with LLMs and create chat apps. + +
    + +
    + +When you're done developing your app, see our [deployment tutorials](/deploy/tutorials), too! diff --git a/content/kb/tutorials/chat.md b/content/kb/tutorials/chat.md index 12423e466..6041de988 100644 --- a/content/kb/tutorials/chat.md +++ b/content/kb/tutorials/chat.md @@ -1,17 +1,17 @@ --- title: Build a basic LLM chat app -slug: /knowledge-base/tutorials/build-conversational-apps +slug: /develop/tutorials/llms/build-conversational-apps --- # Build a basic LLM chat app ## Introduction -The advent of large language models like GPT has revolutionized the ease of developing chat-based applications. Streamlit offers several [Chat elements](/library/api-reference/chat), enabling you to build Graphical User Interfaces (GUIs) for conversational agents or chatbots. Leveraging [session state](/library/advanced-features/session-state) along with these elements allows you to construct anything from a basic chatbot to a more advanced, ChatGPT-like experience using purely Python code. +The advent of large language models like GPT has revolutionized the ease of developing chat-based applications. Streamlit offers several [Chat elements](/develop/api-reference/chat), enabling you to build Graphical User Interfaces (GUIs) for conversational agents or chatbots. Leveraging [session state](/develop/concepts/architecture/session-state) along with these elements allows you to construct anything from a basic chatbot to a more advanced, ChatGPT-like experience using purely Python code. In this tutorial, we'll start by walking through Streamlit's chat elements, `st.chat_message` and `st.chat_input`. Then we'll proceed to construct three distinct applications, each showcasing an increasing level of complexity and functionality: -1. First, we'll [Build a bot that mirrors your input](#build-a-bot-that-mirrors-your-input) to get a feel for the chat elements and how they work. We'll also introduce [session state](/library/advanced-features/session-state) and how it can be used to store the chat history. This section will serve as a foundation for the rest of the tutorial. +1. First, we'll [Build a bot that mirrors your input](#build-a-bot-that-mirrors-your-input) to get a feel for the chat elements and how they work. We'll also introduce [session state](/develop/concepts/architecture/session-state) and how it can be used to store the chat history. This section will serve as a foundation for the rest of the tutorial. 2. Next, you'll learn how to [Build a simple chatbot GUI with streaming](#build-a-simple-chatbot-gui-with-streaming). 3. Finally, we'll [Build a ChatGPT-like app](#build-a-chatgpt-like-app) that leverages session state to remember conversational context, all within less than 50 lines of code. @@ -31,7 +31,7 @@ Before we start building, let's take a closer look at the chat elements we'll us Streamlit offers several commands to help you build conversational apps. These chat elements are designed to be used in conjunction with each other, but you can also use them separately. -[`st.chat_message`](/library/api-reference/chat/st.chat_message) lets you insert a chat message container into the app so you can display messages from the user or the app. Chat containers can contain other Streamlit elements, including charts, tables, text, and more. [`st.chat_input`](/library/api-reference/chat/st.chat_input) lets you display a chat input widget so the user can type in a message. +[`st.chat_message`](/develop/api-reference/chat/st.chat_message) lets you insert a chat message container into the app so you can display messages from the user or the app. Chat containers can contain other Streamlit elements, including charts, tables, text, and more. [`st.chat_input`](/develop/api-reference/chat/st.chat_input) lets you display a chat input widget so the user can type in a message. For an overview of the API, check out this video tutorial by Chanin Nantasenamat ([@dataprofessor](https://www.youtube.com/dataprofessor)), a Senior Developer Advocate at Streamlit. @@ -55,7 +55,7 @@ with st.chat_message("user"):
    -Notice the message is displayed with a default avatar and styling since we passed in `"user"` as the author name. You can also pass in `"assistant"` as the author name to use a different default avatar and styling, or pass in a custom name and avatar. See the [API reference](/library/api-reference/chat/st.chat_message) for more details. +Notice the message is displayed with a default avatar and styling since we passed in `"user"` as the author name. You can also pass in `"assistant"` as the author name to use a different default avatar and styling, or pass in a custom name and avatar. See the [API reference](/develop/api-reference/chat/st.chat_message) for more details. ```python import streamlit as st @@ -99,7 +99,7 @@ Pretty straightforward, right? Now let's combine `st.chat_message` and `st.chat_ ## Build a bot that mirrors your input -In this section, we'll build a bot that mirrors or echoes your input. More specifically, the bot will respond to your input with the same message. We'll use `st.chat_message` to display the user's input and `st.chat_input` to accept user input. We'll also use [session state](/library/advanced-features/session-state) to store the chat history so we can display it in the chat message container. +In this section, we'll build a bot that mirrors or echoes your input. More specifically, the bot will respond to your input with the same message. We'll use `st.chat_message` to display the user's input and `st.chat_input` to accept user input. We'll also use [session state](/develop/concepts/architecture/session-state) to store the chat history so we can display it in the chat message container. First, let's think about the different components we'll need to build our bot: @@ -322,7 +322,7 @@ pip install openai streamlit ### Add OpenAI API key to Streamlit secrets -Next, let's add our OpenAI API key to [Streamlit secrets](/library/advanced-features/secrets-management). We do this by creating `.streamlit/secrets.toml` file in our project directory and adding the following lines to it: +Next, let's add our OpenAI API key to [Streamlit secrets](/develop/concepts/connections/secrets-management). We do this by creating `.streamlit/secrets.toml` file in our project directory and adding the following lines to it: ```toml # .streamlit/secrets.toml diff --git a/content/kb/tutorials/databases/index.md b/content/kb/tutorials/databases/_index.md similarity index 61% rename from content/kb/tutorials/databases/index.md rename to content/kb/tutorials/databases/_index.md index ed910cadb..ec7be325b 100644 --- a/content/kb/tutorials/databases/index.md +++ b/content/kb/tutorials/databases/_index.md @@ -1,16 +1,16 @@ --- title: Connect to data sources -slug: /knowledge-base/tutorials/databases +slug: /develop/tutorials/databases --- # Connect Streamlit to data sources These step-by-step guides demonstrate how to connect Streamlit apps to various databases & APIs. -They use Streamlit's [Secrets management](/streamlit-community-cloud/deploy-your-app/secrets-management) and -[caching](/library/advanced-features/caching) to provide secure and fast data access. +They use Streamlit's [Secrets management](/deploy/streamlit-community-cloud/deploy-your-app/secrets-management) and +[caching](/develop/concepts/architecture/caching) to provide secure and fast data access. - + screenshot @@ -18,7 +18,7 @@ They use Streamlit's [Secrets management](/streamlit-community-cloud/deploy-your - + screenshot @@ -26,7 +26,7 @@ They use Streamlit's [Secrets management](/streamlit-community-cloud/deploy-your - + screenshot @@ -42,7 +42,7 @@ They use Streamlit's [Secrets management](/streamlit-community-cloud/deploy-your - + screenshot @@ -50,7 +50,7 @@ They use Streamlit's [Secrets management](/streamlit-community-cloud/deploy-your - + screenshot @@ -58,7 +58,7 @@ They use Streamlit's [Secrets management](/streamlit-community-cloud/deploy-your - + screenshot @@ -66,7 +66,7 @@ They use Streamlit's [Secrets management](/streamlit-community-cloud/deploy-your - + screenshot @@ -74,7 +74,7 @@ They use Streamlit's [Secrets management](/streamlit-community-cloud/deploy-your - + screenshot @@ -82,7 +82,7 @@ They use Streamlit's [Secrets management](/streamlit-community-cloud/deploy-your - + screenshot @@ -90,7 +90,7 @@ They use Streamlit's [Secrets management](/streamlit-community-cloud/deploy-your - + screenshot @@ -98,7 +98,7 @@ They use Streamlit's [Secrets management](/streamlit-community-cloud/deploy-your - + screenshot @@ -106,7 +106,7 @@ They use Streamlit's [Secrets management](/streamlit-community-cloud/deploy-your - + screenshot @@ -114,7 +114,7 @@ They use Streamlit's [Secrets management](/streamlit-community-cloud/deploy-your - + screenshot @@ -122,7 +122,7 @@ They use Streamlit's [Secrets management](/streamlit-community-cloud/deploy-your - + screenshot @@ -130,7 +130,7 @@ They use Streamlit's [Secrets management](/streamlit-community-cloud/deploy-your - + screenshot diff --git a/content/kb/tutorials/databases/aws-s3.md b/content/kb/tutorials/databases/aws-s3.md index 948a29cd3..f031e08e2 100644 --- a/content/kb/tutorials/databases/aws-s3.md +++ b/content/kb/tutorials/databases/aws-s3.md @@ -1,13 +1,13 @@ --- title: Connect Streamlit to AWS S3 -slug: /knowledge-base/tutorials/databases/aws-s3 +slug: /develop/tutorials/databases/aws-s3 --- # Connect Streamlit to AWS S3 ## Introduction -This guide explains how to securely access files on AWS S3 from Streamlit Community Cloud. It uses [Streamlit FilesConnection](https://github.com/streamlit/files-connection), the [s3fs](https://github.com/dask/s3fs) library and optionally Streamlit's [Secrets management](/library/advanced-features/secrets-management). +This guide explains how to securely access files on AWS S3 from Streamlit Community Cloud. It uses [Streamlit FilesConnection](https://github.com/streamlit/files-connection), the [s3fs](https://github.com/dask/s3fs) library and optionally Streamlit's [Secrets management](/develop/concepts/connections/secrets-management). ## Create an S3 bucket and add a file @@ -76,7 +76,7 @@ Be sure to replace `xxx` above with the values you noted down earlier, and add t ## Copy your app secrets to the cloud -To host your app on Streamlit Community Cloud, you will need to pass your credentials to your deployed app via secrets. Go to the [app dashboard](https://share.streamlit.io/) and in the app's dropdown menu, click on **Edit Secrets**. Copy the content of `secrets.toml` above into the text area. More information is available at [Secrets management](/streamlit-community-cloud/deploy-your-app/secrets-management). +To host your app on Streamlit Community Cloud, you will need to pass your credentials to your deployed app via secrets. Go to the [app dashboard](https://share.streamlit.io/) and in the app's dropdown menu, click on **Edit Secrets**. Copy the content of `secrets.toml` above into the text area. More information is available at [Secrets management](/deploy/streamlit-community-cloud/deploy-your-app/secrets-management). ![Secrets manager screenshot](/images/databases/edit-secrets.png) @@ -110,7 +110,7 @@ for row in df.itertuples(): st.write(f"{row.Owner} has a :{row.Pet}:") ``` -See `st.connection` above? This handles secrets retrieval, setup, result caching and retries. By default, `read()` results are cached without expiring. In this case, we set `ttl=600` to ensure the file contents is cached for no longer than 10 minutes. You can also set `ttl=0` to disable caching. Learn more in [Caching](/library/advanced-features/caching). +See `st.connection` above? This handles secrets retrieval, setup, result caching and retries. By default, `read()` results are cached without expiring. In this case, we set `ttl=600` to ensure the file contents is cached for no longer than 10 minutes. You can also set `ttl=0` to disable caching. Learn more in [Caching](/develop/concepts/architecture/caching). If everything worked out (and you used the example file given above), your app should look like this: diff --git a/content/kb/tutorials/databases/bigquery.md b/content/kb/tutorials/databases/bigquery.md index 03dbbf5b4..bac79c2ae 100644 --- a/content/kb/tutorials/databases/bigquery.md +++ b/content/kb/tutorials/databases/bigquery.md @@ -1,6 +1,6 @@ --- title: Connect Streamlit to Google BigQuery -slug: /knowledge-base/tutorials/databases/bigquery +slug: /develop/tutorials/databases/bigquery --- # Connect Streamlit to Google BigQuery @@ -9,7 +9,7 @@ slug: /knowledge-base/tutorials/databases/bigquery This guide explains how to securely access a BigQuery database from Streamlit Community Cloud. It uses the [google-cloud-bigquery](https://googleapis.dev/python/bigquery/latest/index.html) library and -Streamlit's [Secrets management](/streamlit-community-cloud/deploy-your-app/secrets-management). +Streamlit's [Secrets management](/deploy/streamlit-community-cloud/deploy-your-app/secrets-management). ## Create a BigQuery database @@ -87,7 +87,7 @@ Add this file to `.gitignore` and don't commit it to your GitHub repo! ## Copy your app secrets to the cloud -As the `secrets.toml` file above is not committed to GitHub, you need to pass its content to your deployed app (on Streamlit Community Cloud) separately. Go to the [app dashboard](https://share.streamlit.io/) and in the app's dropdown menu, click on **Edit Secrets**. Copy the content of `secrets.toml` into the text area. More information is available at [Secrets management](/streamlit-community-cloud/deploy-your-app/secrets-management). +As the `secrets.toml` file above is not committed to GitHub, you need to pass its content to your deployed app (on Streamlit Community Cloud) separately. Go to the [app dashboard](https://share.streamlit.io/) and in the app's dropdown menu, click on **Edit Secrets**. Copy the content of `secrets.toml` into the text area. More information is available at [Secrets management](/deploy/streamlit-community-cloud/deploy-your-app/secrets-management). ![Secrets manager screenshot](/images/databases/edit-secrets.png) @@ -135,7 +135,7 @@ for row in rows: st.write("✍️ " + row['word']) ``` -See `st.cache_data` above? Without it, Streamlit would run the query every time the app reruns (e.g. on a widget interaction). With `st.cache_data`, it only runs when the query changes or after 10 minutes (that's what `ttl` is for). Watch out: If your database updates more frequently, you should adapt `ttl` or remove caching so viewers always see the latest data. Learn more in [Caching](/library/advanced-features/caching). +See `st.cache_data` above? Without it, Streamlit would run the query every time the app reruns (e.g. on a widget interaction). With `st.cache_data`, it only runs when the query changes or after 10 minutes (that's what `ttl` is for). Watch out: If your database updates more frequently, you should adapt `ttl` or remove caching so viewers always see the latest data. Learn more in [Caching](/develop/concepts/architecture/caching). Alternatively, you can use pandas to read from BigQuery right into a dataframe! Follow all the above steps, install the [pandas-gbq](https://pandas-gbq.readthedocs.io/en/latest/index.html) library (don't forget to add it to `requirements.txt`!), and call `pandas.read_gbq(query, credentials=credentials)`. More info [in the pandas docs](https://pandas.pydata.org/docs/reference/api/pandas.read_gbq.html). diff --git a/content/kb/tutorials/databases/detabase.md b/content/kb/tutorials/databases/detabase.md index aa83ffa31..73c4c9083 100644 --- a/content/kb/tutorials/databases/detabase.md +++ b/content/kb/tutorials/databases/detabase.md @@ -1,13 +1,13 @@ --- title: Connect Streamlit to Deta Base -slug: /knowledge-base/tutorials/databases/deta-base +slug: /develop/tutorials/databases/deta-base --- # Connect Streamlit to Deta Base ## Introduction -This guide explains how to securely access and write to a [Deta Base](https://deta.space/docs/en/reference/base/about) database from Streamlit Community Cloud. Deta Base is a fully-managed and fast NoSQL database with a focus on end-user simplicity. The data is stored in your own "personal cloud" on [Deta Space](https://deta.space/developers). This guide uses the [Deta Python SDK](https://github.com/deta/deta-python) for Deta Base and Streamlit's [Secrets management](https://www.notion.so/streamlit-community-cloud/deploy-your-app/secrets-management). +This guide explains how to securely access and write to a [Deta Base](https://deta.space/docs/en/reference/base/about) database from Streamlit Community Cloud. Deta Base is a fully-managed and fast NoSQL database with a focus on end-user simplicity. The data is stored in your own "personal cloud" on [Deta Space](https://deta.space/developers). This guide uses the [Deta Python SDK](https://github.com/deta/deta-python) for Deta Base and Streamlit's [Secrets management](/deploy/streamlit-community-cloud/deploy-your-app/secrets-management). ## Create an account and sign in to Deta Space @@ -45,7 +45,7 @@ Add this file to `.gitignore` and don't commit it to your GitHub repo! ## Copy your app secrets to the cloud -As the `secrets.toml` file above is not committed to GitHub, you need to pass its content to your deployed app (on Streamlit Community Cloud) separately. Go to the [app dashboard](https://share.streamlit.io/) and in the app's dropdown menu, click on **Edit Secrets**. Copy the content of `secrets.toml` into the text area. More information is available at [Secrets management](/streamlit-community-cloud/deploy-your-app/secrets-management). +As the `secrets.toml` file above is not committed to GitHub, you need to pass its content to your deployed app (on Streamlit Community Cloud) separately. Go to the [app dashboard](https://share.streamlit.io/) and in the app's dropdown menu, click on **Edit Secrets**. Copy the content of `secrets.toml` into the text area. More information is available at [Secrets management](/deploy/streamlit-community-cloud/deploy-your-app/secrets-management). ![Secrets manager screenshot](/images/databases/edit-secrets.png) diff --git a/content/kb/tutorials/databases/gcs.md b/content/kb/tutorials/databases/gcs.md index 97522c588..0e1e3a4a7 100644 --- a/content/kb/tutorials/databases/gcs.md +++ b/content/kb/tutorials/databases/gcs.md @@ -1,13 +1,13 @@ --- title: Connect Streamlit to Google Cloud Storage -slug: /knowledge-base/tutorials/databases/gcs +slug: /develop/tutorials/databases/gcs --- # Connect Streamlit to Google Cloud Storage ## Introduction -This guide explains how to securely access files on Google Cloud Storage from Streamlit Community Cloud. It uses [Streamlit FilesConnection](https://github.com/streamlit/files-connection), the [gcsfs](https://github.com/fsspec/gcsfs) library and Streamlit's [Secrets management](/library/advanced-features/secrets-management). +This guide explains how to securely access files on Google Cloud Storage from Streamlit Community Cloud. It uses [Streamlit FilesConnection](https://github.com/streamlit/files-connection), the [gcsfs](https://github.com/fsspec/gcsfs) library and Streamlit's [Secrets management](/develop/concepts/connections/secrets-management). ## Create a Google Cloud Storage bucket and add a file @@ -101,7 +101,7 @@ Add this file to `.gitignore` and don't commit it to your GitHub repo! ## Copy your app secrets to the cloud -As the `secrets.toml` file above is not committed to GitHub, you need to pass its content to your deployed app (on Streamlit Community Cloud) separately. Go to the [app dashboard](https://share.streamlit.io/) and in the app's dropdown menu, click on **Edit Secrets**. Copy the content of `secrets.toml` into the text area. More information is available at [Secrets management](/streamlit-community-cloud/deploy-your-app/secrets-management). +As the `secrets.toml` file above is not committed to GitHub, you need to pass its content to your deployed app (on Streamlit Community Cloud) separately. Go to the [app dashboard](https://share.streamlit.io/) and in the app's dropdown menu, click on **Edit Secrets**. Copy the content of `secrets.toml` into the text area. More information is available at [Secrets management](/deploy/streamlit-community-cloud/deploy-your-app/secrets-management). ![Secrets manager screenshot](/images/databases/edit-secrets.png) @@ -135,7 +135,7 @@ for row in df.itertuples(): st.write(f"{row.Owner} has a :{row.Pet}:") ``` -See `st.connection` above? This handles secrets retrieval, setup, result caching and retries. By default, `read()` results are cached without expiring. In this case, we set `ttl=600` to ensure the file contents is cached for no longer than 10 minutes. You can also set `ttl=0` to disable caching. Learn more in [Caching](/library/advanced-features/caching). +See `st.connection` above? This handles secrets retrieval, setup, result caching and retries. By default, `read()` results are cached without expiring. In this case, we set `ttl=600` to ensure the file contents is cached for no longer than 10 minutes. You can also set `ttl=0` to disable caching. Learn more in [Caching](/develop/concepts/architecture/caching). If everything worked out (and you used the example file given above), your app should look like this: diff --git a/content/kb/tutorials/databases/mongodb.md b/content/kb/tutorials/databases/mongodb.md index 4afcc4624..764acc52e 100644 --- a/content/kb/tutorials/databases/mongodb.md +++ b/content/kb/tutorials/databases/mongodb.md @@ -1,13 +1,13 @@ --- title: Connect Streamlit to MongoDB -slug: /knowledge-base/tutorials/databases/mongodb +slug: /develop/tutorials/databases/mongodb --- # Connect Streamlit to MongoDB ## Introduction -This guide explains how to securely access a **_remote_** MongoDB database from Streamlit Community Cloud. It uses the [PyMongo](https://github.com/mongodb/mongo-python-driver) library and Streamlit's [Secrets management](/streamlit-community-cloud/deploy-your-app/secrets-management). +This guide explains how to securely access a **_remote_** MongoDB database from Streamlit Community Cloud. It uses the [PyMongo](https://github.com/mongodb/mongo-python-driver) library and Streamlit's [Secrets management](/deploy/streamlit-community-cloud/deploy-your-app/secrets-management). ## Create a MongoDB Database @@ -49,7 +49,7 @@ Add this file to `.gitignore` and don't commit it to your GitHub repo! ## Copy your app secrets to the cloud -As the `secrets.toml` file above is not committed to GitHub, you need to pass its content to your deployed app (on Streamlit Community Cloud) separately. Go to the [app dashboard](https://share.streamlit.io/) and in the app's dropdown menu, click on **Edit Secrets**. Copy the content of `secrets.toml` into the text area. More information is available at [Secrets management](/streamlit-community-cloud/deploy-your-app/secrets-management). +As the `secrets.toml` file above is not committed to GitHub, you need to pass its content to your deployed app (on Streamlit Community Cloud) separately. Go to the [app dashboard](https://share.streamlit.io/) and in the app's dropdown menu, click on **Edit Secrets**. Copy the content of `secrets.toml` into the text area. More information is available at [Secrets management](/deploy/streamlit-community-cloud/deploy-your-app/secrets-management). ![Secrets manager screenshot](/images/databases/edit-secrets.png) @@ -96,7 +96,7 @@ for item in items: st.write(f"{item['name']} has a :{item['pet']}:") ``` -See `st.cache_data` above? Without it, Streamlit would run the query every time the app reruns (e.g. on a widget interaction). With `st.cache_data`, it only runs when the query changes or after 10 minutes (that's what `ttl` is for). Watch out: If your database updates more frequently, you should adapt `ttl` or remove caching so viewers always see the latest data. Learn more in [Caching](/library/advanced-features/caching). +See `st.cache_data` above? Without it, Streamlit would run the query every time the app reruns (e.g. on a widget interaction). With `st.cache_data`, it only runs when the query changes or after 10 minutes (that's what `ttl` is for). Watch out: If your database updates more frequently, you should adapt `ttl` or remove caching so viewers always see the latest data. Learn more in [Caching](/develop/concepts/architecture/caching). If everything worked out (and you used the example data we created above), your app should look like this: diff --git a/content/kb/tutorials/databases/mssql.md b/content/kb/tutorials/databases/mssql.md index 1c734d3d7..3f5570edc 100644 --- a/content/kb/tutorials/databases/mssql.md +++ b/content/kb/tutorials/databases/mssql.md @@ -1,13 +1,13 @@ --- title: Connect Streamlit to Microsoft SQL Server -slug: /knowledge-base/tutorials/databases/mssql +slug: /develop/tutorials/databases/mssql --- # Connect Streamlit to Microsoft SQL Server ## Introduction -This guide explains how to securely access a **_remote_** Microsoft SQL Server database from Streamlit Community Cloud. It uses the [pyodbc](https://github.com/mkleehammer/pyodbc/wiki) library and Streamlit's [Secrets management](/streamlit-community-cloud/deploy-your-app/secrets-management). +This guide explains how to securely access a **_remote_** Microsoft SQL Server database from Streamlit Community Cloud. It uses the [pyodbc](https://github.com/mkleehammer/pyodbc/wiki) library and Streamlit's [Secrets management](/deploy/streamlit-community-cloud/deploy-your-app/secrets-management). ## Create an SQL Server database @@ -120,7 +120,7 @@ And add this file to `.gitignore` and don't commit it to your GitHub repo. ## Copy your app secrets to Streamlit Community Cloud -As the `secrets.toml` file above is not committed to GitHub, you need to pass its content to your deployed app (on Streamlit Community Cloud) separately. Go to the [app dashboard](https://share.streamlit.io/) and in the app's dropdown menu, click on **Edit Secrets**. Copy the content of `secrets.toml` into the text area. More information is available at [Secrets management](/streamlit-community-cloud/deploy-your-app/secrets-management). +As the `secrets.toml` file above is not committed to GitHub, you need to pass its content to your deployed app (on Streamlit Community Cloud) separately. Go to the [app dashboard](https://share.streamlit.io/) and in the app's dropdown menu, click on **Edit Secrets**. Copy the content of `secrets.toml` into the text area. More information is available at [Secrets management](/deploy/streamlit-community-cloud/deploy-your-app/secrets-management). ![Secrets manager screenshot](/images/databases/edit-secrets.png) @@ -186,7 +186,7 @@ for row in rows: ``` -See `st.cache_data` above? Without it, Streamlit would run the query every time the app reruns (e.g. on a widget interaction). With `st.cache_data`, it only runs when the query changes or after 10 minutes (that's what `ttl` is for). Watch out: If your database updates more frequently, you should adapt `ttl` or remove caching so viewers always see the latest data. Learn more in [Caching](/library/advanced-features/caching). +See `st.cache_data` above? Without it, Streamlit would run the query every time the app reruns (e.g. on a widget interaction). With `st.cache_data`, it only runs when the query changes or after 10 minutes (that's what `ttl` is for). Watch out: If your database updates more frequently, you should adapt `ttl` or remove caching so viewers always see the latest data. Learn more in [Caching](/develop/concepts/architecture/caching). If everything worked out (and you used the example table we created above), your app should look like this: diff --git a/content/kb/tutorials/databases/mysql.md b/content/kb/tutorials/databases/mysql.md index 48619dbd8..eeee3012a 100644 --- a/content/kb/tutorials/databases/mysql.md +++ b/content/kb/tutorials/databases/mysql.md @@ -1,13 +1,13 @@ --- title: Connect Streamlit to MySQL -slug: /knowledge-base/tutorials/databases/mysql +slug: /develop/tutorials/databases/mysql --- # Connect Streamlit to MySQL ## Introduction -This guide explains how to securely access a **_remote_** MySQL database from Streamlit Community Cloud. It uses [st.connection](/library/api-reference/connections/st.connection) and Streamlit's [Secrets management](/library/advanced-features/secrets-management). The below example code will **only work on Streamlit version >= 1.28**, when `st.connection` was added. +This guide explains how to securely access a **_remote_** MySQL database from Streamlit Community Cloud. It uses [st.connection](/develop/api-reference/connections/st.connection) and Streamlit's [Secrets management](/develop/concepts/connections/secrets-management). The below example code will **only work on Streamlit version >= 1.28**, when `st.connection` was added. ## Create a MySQL database @@ -35,7 +35,7 @@ INSERT INTO mytable VALUES ('Mary', 'dog'), ('John', 'cat'), ('Robert', 'bird'); ## Add username and password to your local app secrets -Your local Streamlit app will read secrets from a file `.streamlit/secrets.toml` in your app's root directory. Learn more about [Streamlit secrets management here](/library/advanced-features/secrets-management). Create this file if it doesn't exist yet and add the database name, user, and password of your MySQL server as shown below: +Your local Streamlit app will read secrets from a file `.streamlit/secrets.toml` in your app's root directory. Learn more about [Streamlit secrets management here](/develop/concepts/connections/secrets-management). Create this file if it doesn't exist yet and add the database name, user, and password of your MySQL server as shown below: ```toml # .streamlit/secrets.toml @@ -59,7 +59,7 @@ Add this file to `.gitignore` and don't commit it to your GitHub repo! ## Copy your app secrets to the cloud -As the `secrets.toml` file above is not committed to GitHub, you need to pass its content to your deployed app (on Streamlit Community Cloud) separately. Go to the [app dashboard](https://share.streamlit.io/) and in the app's dropdown menu, click on **Edit Secrets**. Copy the content of `secrets.toml` into the text area. More information is available at [Secrets management](/streamlit-community-cloud/deploy-your-app/secrets-management). +As the `secrets.toml` file above is not committed to GitHub, you need to pass its content to your deployed app (on Streamlit Community Cloud) separately. Go to the [app dashboard](https://share.streamlit.io/) and in the app's dropdown menu, click on **Edit Secrets**. Copy the content of `secrets.toml` into the text area. More information is available at [Secrets management](/deploy/streamlit-community-cloud/deploy-your-app/secrets-management). ![Secrets manager screenshot](/images/databases/edit-secrets.png) @@ -93,7 +93,7 @@ for row in df.itertuples(): st.write(f"{row.name} has a :{row.pet}:") ``` -See `st.connection` above? This handles secrets retrieval, setup, query caching and retries. By default, `query()` results are cached without expiring. In this case, we set `ttl=600` to ensure the query result is cached for no longer than 10 minutes. You can also set `ttl=0` to disable caching. Learn more in [Caching](/library/advanced-features/caching). +See `st.connection` above? This handles secrets retrieval, setup, query caching and retries. By default, `query()` results are cached without expiring. In this case, we set `ttl=600` to ensure the query result is cached for no longer than 10 minutes. You can also set `ttl=0` to disable caching. Learn more in [Caching](/develop/concepts/architecture/caching). If everything worked out (and you used the example table we created above), your app should look like this: diff --git a/content/kb/tutorials/databases/postgresql.md b/content/kb/tutorials/databases/postgresql.md index 3b2896e7e..256ab4291 100644 --- a/content/kb/tutorials/databases/postgresql.md +++ b/content/kb/tutorials/databases/postgresql.md @@ -1,13 +1,13 @@ --- title: Connect Streamlit to PostgreSQL -slug: /knowledge-base/tutorials/databases/postgresql +slug: /develop/tutorials/databases/postgresql --- # Connect Streamlit to PostgreSQL ## Introduction -This guide explains how to securely access a **_remote_** PostgreSQL database from Streamlit Community Cloud. It uses [st.connection](/library/api-reference/connections/st.connection) and Streamlit's [Secrets management](/library/advanced-features/secrets-management). The below example code will **only work on Streamlit version >= 1.28**, when `st.connection` was added. +This guide explains how to securely access a **_remote_** PostgreSQL database from Streamlit Community Cloud. It uses [st.connection](/develop/api-reference/connections/st.connection) and Streamlit's [Secrets management](/develop/concepts/connections/secrets-management). The below example code will **only work on Streamlit version >= 1.28**, when `st.connection` was added. ## Create a PostgreSQL database @@ -55,7 +55,7 @@ Add this file to `.gitignore` and don't commit it to your GitHub repo! ## Copy your app secrets to the cloud -As the `secrets.toml` file above is not committed to GitHub, you need to pass its content to your deployed app (on Streamlit Community Cloud) separately. Go to the [app dashboard](https://share.streamlit.io/) and in the app's dropdown menu, click on **Edit Secrets**. Copy the content of `secrets.toml` into the text area. More information is available at [Secrets management](/streamlit-community-cloud/deploy-your-app/secrets-management). +As the `secrets.toml` file above is not committed to GitHub, you need to pass its content to your deployed app (on Streamlit Community Cloud) separately. Go to the [app dashboard](https://share.streamlit.io/) and in the app's dropdown menu, click on **Edit Secrets**. Copy the content of `secrets.toml` into the text area. More information is available at [Secrets management](/deploy/streamlit-community-cloud/deploy-your-app/secrets-management). ![Secrets manager screenshot](/images/databases/edit-secrets.png) @@ -89,7 +89,7 @@ for row in df.itertuples(): st.write(f"{row.name} has a :{row.pet}:") ``` -See `st.connection` above? This handles secrets retrieval, setup, query caching and retries. By default, `query()` results are cached without expiring. In this case, we set `ttl="10m"` to ensure the query result is cached for no longer than 10 minutes. You can also set `ttl=0` to disable caching. Learn more in [Caching](/library/advanced-features/caching). +See `st.connection` above? This handles secrets retrieval, setup, query caching and retries. By default, `query()` results are cached without expiring. In this case, we set `ttl="10m"` to ensure the query result is cached for no longer than 10 minutes. You can also set `ttl=0` to disable caching. Learn more in [Caching](/develop/concepts/architecture/caching). If everything worked out (and you used the example table we created above), your app should look like this: diff --git a/content/kb/tutorials/databases/private-gsheet.md b/content/kb/tutorials/databases/private-gsheet.md index 76edbfe37..b7a505fcb 100644 --- a/content/kb/tutorials/databases/private-gsheet.md +++ b/content/kb/tutorials/databases/private-gsheet.md @@ -1,15 +1,15 @@ --- title: Connect Streamlit to a private Google Sheet -slug: /knowledge-base/tutorials/databases/private-gsheet +slug: /develop/tutorials/databases/private-gsheet --- # Connect Streamlit to a private Google Sheet ## Introduction -This guide explains how to securely access a private Google Sheet from Streamlit Community Cloud. It uses [st.connection](/library/api-reference/connections/st.connection), [Streamlit GSheetsConnection](https://github.com/streamlit/gsheets-connection), and Streamlit's [Secrets management](/library/advanced-features/secrets-management). +This guide explains how to securely access a private Google Sheet from Streamlit Community Cloud. It uses [st.connection](/develop/api-reference/connections/st.connection), [Streamlit GSheetsConnection](https://github.com/streamlit/gsheets-connection), and Streamlit's [Secrets management](/develop/concepts/connections/secrets-management). -If you are fine with enabling link sharing for your Google Sheet (i.e. everyone with the link can view it), the guide [Connect Streamlit to a public Google Sheet](/knowledge-base/tutorials/databases/public-gsheet) shows a simpler method of doing this. If your Sheet contains sensitive information and you cannot enable link sharing, keep on reading. +If you are fine with enabling link sharing for your Google Sheet (i.e. everyone with the link can view it), the guide [Connect Streamlit to a public Google Sheet](/develop/tutorials/databases/public-gsheet) shows a simpler method of doing this. If your Sheet contains sensitive information and you cannot enable link sharing, keep on reading. ### Prerequisites @@ -136,7 +136,7 @@ df = conn.read( ) ``` -In this case, we set `ttl="10m"` to ensure the query result is cached for no longer than 10 minutes. You can also set `ttl=0` to disable caching. Learn more in [Caching](/library/advanced-features/caching). We've declared optional parameters `usecols=[0,1]` and `nrows=3` for `pandas` to use under the hood. +In this case, we set `ttl="10m"` to ensure the query result is cached for no longer than 10 minutes. You can also set `ttl=0` to disable caching. Learn more in [Caching](/develop/concepts/architecture/caching). We've declared optional parameters `usecols=[0,1]` and `nrows=3` for `pandas` to use under the hood. If everything worked out (and you used the example table we created above), your app should look like this: @@ -146,5 +146,5 @@ If everything worked out (and you used the example table we created above), your This tutorial assumes a local Streamlit app, however you can also connect to Google Sheets from apps hosted in Community Cloud. The main additional steps are: -- [Include information about dependencies](/streamlit-community-cloud/deploy-your-app/app-dependencies) using a `requirements.txt` file with `st-gsheets-connection` and any other dependencies. -- [Add your secrets](/streamlit-community-cloud/deploy-your-app/secrets-management#deploy-an-app-and-set-up-secrets) to your Community Cloud app. +- [Include information about dependencies](/deploy/streamlit-community-cloud/deploy-your-app/app-dependencies) using a `requirements.txt` file with `st-gsheets-connection` and any other dependencies. +- [Add your secrets](/deploy/streamlit-community-cloud/deploy-your-app/secrets-management#deploy-an-app-and-set-up-secrets) to your Community Cloud app. diff --git a/content/kb/tutorials/databases/public-gsheet.md b/content/kb/tutorials/databases/public-gsheet.md index 41507e539..72612795e 100644 --- a/content/kb/tutorials/databases/public-gsheet.md +++ b/content/kb/tutorials/databases/public-gsheet.md @@ -1,13 +1,13 @@ --- title: Connect Streamlit to a public Google Sheet -slug: /knowledge-base/tutorials/databases/public-gsheet +slug: /develop/tutorials/databases/public-gsheet --- # Connect Streamlit to a public Google Sheet ## Introduction -This guide explains how to securely access a public Google Sheet from Streamlit. It uses [st.connection](/library/api-reference/connections/st.connection), [Streamlit GSheetsConnection](https://github.com/streamlit/gsheets-connection), and Streamlit's [Secrets management](/library/advanced-features/secrets-management). +This guide explains how to securely access a public Google Sheet from Streamlit. It uses [st.connection](/develop/api-reference/connections/st.connection), [Streamlit GSheetsConnection](https://github.com/streamlit/gsheets-connection), and Streamlit's [Secrets management](/develop/concepts/connections/secrets-management). This method requires you to enable link sharing for your Google Sheet. While the sharing link will not appear in your code (and actually acts as sort of a password!), someone with the link can get all the data in the Sheet. If you don't want this, follow the (more complicated) guide to [Connect Streamlit to a private Google Sheet](private-gsheet). @@ -83,7 +83,7 @@ df = conn.read( ) ``` -In this case, we set `ttl="10m"` to ensure the query result is cached for no longer than 10 minutes. You can also set `ttl=0` to disable caching. Learn more in [Caching](/library/advanced-features/caching). We've declared optional parameters `usecols=[0,1]` and `nrows=3` for `pandas` to use under the hood. +In this case, we set `ttl="10m"` to ensure the query result is cached for no longer than 10 minutes. You can also set `ttl=0` to disable caching. Learn more in [Caching](/develop/concepts/architecture/caching). We've declared optional parameters `usecols=[0,1]` and `nrows=3` for `pandas` to use under the hood. If everything worked out (and you used the example table we created above), your app should look like this: @@ -93,5 +93,5 @@ If everything worked out (and you used the example table we created above), your This tutorial assumes a local Streamlit app, however you can also connect to Google Sheets from apps hosted in Community Cloud. The main additional steps are: -- [Include information about dependencies](/streamlit-community-cloud/deploy-your-app/app-dependencies) using a `requirements.txt` file with `st-gsheets-connection` and any other dependencies. -- [Add your secrets](/streamlit-community-cloud/deploy-your-app/secrets-management#deploy-an-app-and-set-up-secrets) to your Community Cloud app. +- [Include information about dependencies](/deploy/streamlit-community-cloud/deploy-your-app/app-dependencies) using a `requirements.txt` file with `st-gsheets-connection` and any other dependencies. +- [Add your secrets](/deploy/streamlit-community-cloud/deploy-your-app/secrets-management#deploy-an-app-and-set-up-secrets) to your Community Cloud app. diff --git a/content/kb/tutorials/databases/snowflake.md b/content/kb/tutorials/databases/snowflake.md index a4fda770b..743bce6c6 100644 --- a/content/kb/tutorials/databases/snowflake.md +++ b/content/kb/tutorials/databases/snowflake.md @@ -1,13 +1,13 @@ --- title: Connect Streamlit to Snowflake -slug: /knowledge-base/tutorials/databases/snowflake +slug: /develop/tutorials/databases/snowflake --- # Connect Streamlit to Snowflake ## Introduction -This guide explains how to securely access a Snowflake database from Streamlit. It uses [st.connection](/library/api-reference/connections/st.connection), the [Snowpark library](https://docs.snowflake.com/en/developer-guide/snowpark/python/index) and Streamlit's [Secrets management](/library/advanced-features/secrets-management). The below example code **will only work on Streamlit version >= 1.28**, when `st.connection` was added. +This guide explains how to securely access a Snowflake database from Streamlit. It uses [st.connection](/develop/api-reference/connections/st.connection), the [Snowpark library](https://docs.snowflake.com/en/developer-guide/snowpark/python/index) and Streamlit's [Secrets management](/develop/concepts/connections/secrets-management). The below example code **will only work on Streamlit version >= 1.28**, when `st.connection` was added. ## Create a Snowflake database @@ -66,7 +66,7 @@ pip install snowflake-snowpark-python ## Add connection parameters to your local app secrets -Your local Streamlit app will read secrets from a file `.streamlit/secrets.toml` in your app’s root directory. Learn more about [Streamlit secrets management here](/library/advanced-features/secrets-management). Create this file if it doesn’t exist yet and add your Snowflake username, password, [account identifier](https://docs.snowflake.com/en/user-guide/admin-account-identifier.html), and the name of your warehouse, database, and schema as shown below: +Your local Streamlit app will read secrets from a file `.streamlit/secrets.toml` in your app’s root directory. Learn more about [Streamlit secrets management here](/develop/concepts/connections/secrets-management). Create this file if it doesn’t exist yet and add your Snowflake username, password, [account identifier](https://docs.snowflake.com/en/user-guide/admin-account-identifier.html), and the name of your warehouse, database, and schema as shown below: ```toml # .streamlit/secrets.toml @@ -110,7 +110,7 @@ for row in df.itertuples(): st.write(f"{row.NAME} has a :{row.PET}:") ``` -See `st.connection` above? This handles secrets retrieval, setup, query caching and retries. By default, `query()` results are cached without expiring. In this case, we set `ttl=600` to ensure the query result is cached for no longer than 10 minutes. You can also set `ttl=0` to disable caching. Learn more in [Caching](/library/advanced-features/caching). +See `st.connection` above? This handles secrets retrieval, setup, query caching and retries. By default, `query()` results are cached without expiring. In this case, we set `ttl=600` to ensure the query result is cached for no longer than 10 minutes. You can also set `ttl=0` to disable caching. Learn more in [Caching](/develop/concepts/architecture/caching). If everything worked out (and you used the example table we created above), your app should look like this: @@ -118,7 +118,7 @@ If everything worked out (and you used the example table we created above), your ### Using a Snowpark Session -The same [SnowflakeConnection](/library/api-reference/connections/st.connections.snowflakeconnection) used above also provides access to the [Snowpark Session](https://docs.snowflake.com/en/developer-guide/snowpark/reference/python/session.html) for DataFrame-style operations that run natively inside Snowflake. Using this approach, you can rewrite the app above as follows: +The same [SnowflakeConnection](/develop/api-reference/connections/st.connections.snowflakeconnection) used above also provides access to the [Snowpark Session](https://docs.snowflake.com/en/developer-guide/snowpark/reference/python/session.html) for DataFrame-style operations that run natively inside Snowflake. Using this approach, you can rewrite the app above as follows: ```python # streamlit_app.py @@ -147,5 +147,5 @@ If everything worked out (and you used the example table we created above), your This tutorial assumes a local Streamlit app, however you can also connect to Snowflake from apps hosted in Community Cloud. The main additional steps are: -- [Include information about dependencies](/streamlit-community-cloud/deploy-your-app/app-dependencies) using a `requirements.txt` file with `snowflake-snowpark-python` and any other dependencies. -- [Add your secrets](/streamlit-community-cloud/deploy-your-app/secrets-management#deploy-an-app-and-set-up-secrets) to your Community Cloud app. +- [Include information about dependencies](/deploy/streamlit-community-cloud/deploy-your-app/app-dependencies) using a `requirements.txt` file with `snowflake-snowpark-python` and any other dependencies. +- [Add your secrets](/deploy/streamlit-community-cloud/deploy-your-app/secrets-management#deploy-an-app-and-set-up-secrets) to your Community Cloud app. diff --git a/content/kb/tutorials/databases/supabase.md b/content/kb/tutorials/databases/supabase.md index e65a6b184..1ac1c44e6 100644 --- a/content/kb/tutorials/databases/supabase.md +++ b/content/kb/tutorials/databases/supabase.md @@ -1,17 +1,17 @@ --- title: Connect Streamlit to Supabase -slug: /knowledge-base/tutorials/databases/supabase +slug: /develop/tutorials/databases/supabase --- # Connect Streamlit to Supabase ## Introduction -This guide explains how to securely access a Supabase instance from Streamlit Community Cloud. It uses [st.connection](/library/api-reference/connections/st.connection), [Streamlit Supabase Connector](https://github.com/SiddhantSadangi/st_supabase_connection/tree/main) (a community-built connection developed by [@SiddhantSadangi](https://github.com/SiddhantSadangi)) and Streamlit's [Secrets management](/streamlit-community-cloud/deploy-your-app/secrets-management). Supabase is the open source Firebase alternative and is based on PostgreSQL. +This guide explains how to securely access a Supabase instance from Streamlit Community Cloud. It uses [st.connection](/develop/api-reference/connections/st.connection), [Streamlit Supabase Connector](https://github.com/SiddhantSadangi/st_supabase_connection/tree/main) (a community-built connection developed by [@SiddhantSadangi](https://github.com/SiddhantSadangi)) and Streamlit's [Secrets management](/deploy/streamlit-community-cloud/deploy-your-app/secrets-management). Supabase is the open source Firebase alternative and is based on PostgreSQL. -Community-built connections, such as the [Streamlit Supabase Connector](https://github.com/SiddhantSadangi/st_supabase_connection/tree/main), extend and build on the `st.connection` interface and make it easier than ever to build Streamlit apps with a wide variety of data sources. These type of connections work exactly the same as [the ones built into Streamlit](/library/api-reference/connections) and have access to all the same capabilities. +Community-built connections, such as the [Streamlit Supabase Connector](https://github.com/SiddhantSadangi/st_supabase_connection/tree/main), extend and build on the `st.connection` interface and make it easier than ever to build Streamlit apps with a wide variety of data sources. These type of connections work exactly the same as [the ones built into Streamlit](/develop/api-reference/connections) and have access to all the same capabilities. @@ -84,7 +84,7 @@ SUPABASE_URL = "xxxx" SUPABASE_KEY = "xxxx" ``` -Replace `xxxx` above with your Project URL and API key from [Step 1](/knowledge-base/tutorials/databases/supabase#sign-in-to-supabase-and-create-a-project). +Replace `xxxx` above with your Project URL and API key from [Step 1](/develop/tutorials/databases/supabase#sign-in-to-supabase-and-create-a-project). @@ -94,7 +94,7 @@ Add this file to `.gitignore` and don't commit it to your GitHub repo! ## Copy your app secrets to the cloud -As the `secrets.toml` file above is not committed to GitHub, you need to pass its content to your deployed app (on Streamlit Community Cloud) separately. Go to the [app dashboard](https://share.streamlit.io/) and in the app's dropdown menu, click on **Edit Secrets**. Copy the content of `secrets.toml` into the text area. More information is available at [Secrets management](/streamlit-community-cloud/deploy-your-app/secrets-management). +As the `secrets.toml` file above is not committed to GitHub, you need to pass its content to your deployed app (on Streamlit Community Cloud) separately. Go to the [app dashboard](https://share.streamlit.io/) and in the app's dropdown menu, click on **Edit Secrets**. Copy the content of `secrets.toml` into the text area. More information is available at [Secrets management](/deploy/streamlit-community-cloud/deploy-your-app/secrets-management). ![Secrets manager screenshot](/images/databases/edit-secrets.png) @@ -111,7 +111,7 @@ st-supabase-connection==x.x.x We've used the `st-supabase-connection` library here in combination with `st.connection` to benefit from the ease of setting up the data connection, managing your credentials, and Streamlit's caching capabilities that native and community-built connections provide. -You can however still directly use the [Supabase Python Client Library](https://pypi.org/project/supabase/) library if you prefer, but you'll need to write more code to set up the connection and cache the results. See [Using the Supabase Python Client Library](/knowledge-base/tutorials/databases/supabase#using-the-supabase-python-client-library) below for an example. +You can however still directly use the [Supabase Python Client Library](https://pypi.org/project/supabase/) library if you prefer, but you'll need to write more code to set up the connection and cache the results. See [Using the Supabase Python Client Library](/develop/tutorials/databases/supabase#using-the-supabase-python-client-library) below for an example. @@ -137,13 +137,13 @@ for row in rows.data: ``` -See `st.connection` above? This handles secrets retrieval, setup, query caching and retries. By default, `query()` results are cached without expiring. In this case, we set `ttl="10m"` to ensure the query result is cached for no longer than 10 minutes. You can also set `ttl=0` to disable caching. Learn more in [Caching](/library/advanced-features/caching). +See `st.connection` above? This handles secrets retrieval, setup, query caching and retries. By default, `query()` results are cached without expiring. In this case, we set `ttl="10m"` to ensure the query result is cached for no longer than 10 minutes. You can also set `ttl=0` to disable caching. Learn more in [Caching](/develop/concepts/architecture/caching). If everything worked out (and you used the example table we created above), your app should look like this: ![Finished app screenshot](/images/databases/supabase-10.png) -As Supabase uses PostgresSQL under the hood, you can also connect to Supabase by using the connection string Supabase provides under Settings > Databases. From there, you can refer to the [PostgresSQL tutorial](/knowledge-base/tutorials/databases/postgresql) to connect to your database. +As Supabase uses PostgresSQL under the hood, you can also connect to Supabase by using the connection string Supabase provides under Settings > Databases. From there, you can refer to the [PostgresSQL tutorial](/develop/tutorials/databases/postgresql) to connect to your database. ## Using the Supabase Python Client Library @@ -202,4 +202,4 @@ If you prefer to use the [Supabase Python Client Library](https://pypi.org/proje st.write(f"{row['name']} has a :{row['pet']}:") ``` - See `st.cache_data` above? Without it, Streamlit would run the query every time the app reruns (e.g. on a widget interaction). With `st.cache_data`, it only runs when the query changes or after 10 minutes (that's what `ttl` is for). Watch out: If your database updates more frequently, you should adapt `ttl` or remove caching so viewers always see the latest data. Learn more in [Caching](/library/advanced-features/caching). + See `st.cache_data` above? Without it, Streamlit would run the query every time the app reruns (e.g. on a widget interaction). With `st.cache_data`, it only runs when the query changes or after 10 minutes (that's what `ttl` is for). Watch out: If your database updates more frequently, you should adapt `ttl` or remove caching so viewers always see the latest data. Learn more in [Caching](/develop/concepts/architecture/caching). diff --git a/content/kb/tutorials/databases/tableau.md b/content/kb/tutorials/databases/tableau.md index 6a5f6e65b..277d4764a 100644 --- a/content/kb/tutorials/databases/tableau.md +++ b/content/kb/tutorials/databases/tableau.md @@ -1,13 +1,13 @@ --- title: Connect Streamlit to Tableau -slug: /knowledge-base/tutorials/databases/tableau +slug: /develop/tutorials/databases/tableau --- # Connect Streamlit to Tableau ## Introduction -This guide explains how to securely access data on Tableau from Streamlit Community Cloud. It uses the [tableauserverclient](https://tableau.github.io/server-client-python/#) library and Streamlit's [Secrets management](/streamlit-community-cloud/deploy-your-app/secrets-management). +This guide explains how to securely access data on Tableau from Streamlit Community Cloud. It uses the [tableauserverclient](https://tableau.github.io/server-client-python/#) library and Streamlit's [Secrets management](/deploy/streamlit-community-cloud/deploy-your-app/secrets-management). ## Create a Tableau site @@ -61,7 +61,7 @@ Add this file to `.gitignore` and don't commit it to your GitHub repo! ## Copy your app secrets to the cloud -As the `secrets.toml` file above is not committed to GitHub, you need to pass its content to your deployed app (on Streamlit Community Cloud) separately. Go to the [app dashboard](https://share.streamlit.io/) and in the app's dropdown menu, click on **Edit Secrets**. Copy the content of `secrets.toml` into the text area. More information is available at [Secrets management](/streamlit-community-cloud/deploy-your-app/secrets-management). +As the `secrets.toml` file above is not committed to GitHub, you need to pass its content to your deployed app (on Streamlit Community Cloud) separately. Go to the [app dashboard](https://share.streamlit.io/) and in the app's dropdown menu, click on **Edit Secrets**. Copy the content of `secrets.toml` into the text area. More information is available at [Secrets management](/deploy/streamlit-community-cloud/deploy-your-app/secrets-management). ![Secrets manager screenshot](/images/databases/edit-secrets.png) @@ -142,7 +142,7 @@ st.write(f"And here's the data for view *{view_name}*:") st.write(pd.read_csv(StringIO(view_csv))) ``` -See `st.cache_data` above? Without it, Streamlit would run the query every time the app reruns (e.g. on a widget interaction). With `st.cache_data`, it only runs when the query changes or after 10 minutes (that's what `ttl` is for). Watch out: If your database updates more frequently, you should adapt `ttl` or remove caching so viewers always see the latest data. Learn more in [Caching](/library/advanced-features/caching). +See `st.cache_data` above? Without it, Streamlit would run the query every time the app reruns (e.g. on a widget interaction). With `st.cache_data`, it only runs when the query changes or after 10 minutes (that's what `ttl` is for). Watch out: If your database updates more frequently, you should adapt `ttl` or remove caching so viewers always see the latest data. Learn more in [Caching](/develop/concepts/architecture/caching). If everything worked out, your app should look like this (can differ based on your workbooks): diff --git a/content/kb/tutorials/databases/tidb.md b/content/kb/tutorials/databases/tidb.md index 62cdba010..af2611c46 100644 --- a/content/kb/tutorials/databases/tidb.md +++ b/content/kb/tutorials/databases/tidb.md @@ -1,13 +1,13 @@ --- title: Connect Streamlit to TiDB -slug: /knowledge-base/tutorials/databases/tidb +slug: /develop/tutorials/databases/tidb --- # Connect Streamlit to TiDB ## Introduction -This guide explains how to securely access a **_remote_** TiDB database from Streamlit Community Cloud. It uses [st.connection](/library/api-reference/connections/st.connection) and Streamlit's [Secrets management](/library/advanced-features/secrets-management). The below example code will **only work on Streamlit version >= 1.28**, when `st.connection` was added. +This guide explains how to securely access a **_remote_** TiDB database from Streamlit Community Cloud. It uses [st.connection](/develop/api-reference/connections/st.connection) and Streamlit's [Secrets management](/develop/concepts/connections/secrets-management). The below example code will **only work on Streamlit version >= 1.28**, when `st.connection` was added. [TiDB](https://www.pingcap.com/tidb/) is an open-source, MySQL-compatible database that supports Hybrid Transactional and Analytical Processing (HTAP) workloads. [TiDB Cloud](https://tidb.cloud/) is a fully managed cloud database service that simplifies the deployment and management of TiDB databases for developers. @@ -61,7 +61,7 @@ INSERT INTO mytable VALUES ('Mary', 'dog'), ('John', 'cat'), ('Robert', 'bird'); ## Add username and password to your local app secrets -Your local Streamlit app will read secrets from a file `.streamlit/secrets.toml` in your app's root directory. Learn more about [Streamlit secrets management here](/library/advanced-features/secrets-management). Create this file if it doesn't exist yet and add host, username and password of your TiDB cluster as shown below: +Your local Streamlit app will read secrets from a file `.streamlit/secrets.toml` in your app's root directory. Learn more about [Streamlit secrets management here](/develop/concepts/connections/secrets-management). Create this file if it doesn't exist yet and add host, username and password of your TiDB cluster as shown below: ```toml # .streamlit/secrets.toml @@ -85,7 +85,7 @@ Add this file to `.gitignore` and don't commit it to your GitHub repo! ## Copy your app secrets to the cloud -As the `secrets.toml` file above is not committed to GitHub, you need to pass its content to your deployed app (on Streamlit Community Cloud) separately. Go to the [app dashboard](https://share.streamlit.io/) and in the app's dropdown menu, click on **Edit Secrets**. Copy the content of `secrets.toml` into the text area. More information is available at [Secrets management](/streamlit-community-cloud/deploy-your-app/secrets-management). +As the `secrets.toml` file above is not committed to GitHub, you need to pass its content to your deployed app (on Streamlit Community Cloud) separately. Go to the [app dashboard](https://share.streamlit.io/) and in the app's dropdown menu, click on **Edit Secrets**. Copy the content of `secrets.toml` into the text area. More information is available at [Secrets management](/deploy/streamlit-community-cloud/deploy-your-app/secrets-management). ![Secrets manager screenshot](/images/databases/edit-secrets.png) @@ -119,7 +119,7 @@ for row in df.itertuples(): st.write(f"{row.name} has a :{row.pet}:") ``` -See `st.connection` above? This handles secrets retrieval, setup, query caching and retries. By default, `query()` results are cached without expiring. In this case, we set `ttl=600` to ensure the query result is cached for no longer than 10 minutes. You can also set `ttl=0` to disable caching. Learn more in [Caching](/library/advanced-features/caching). +See `st.connection` above? This handles secrets retrieval, setup, query caching and retries. By default, `query()` results are cached without expiring. In this case, we set `ttl=600` to ensure the query result is cached for no longer than 10 minutes. You can also set `ttl=0` to disable caching. Learn more in [Caching](/develop/concepts/architecture/caching). If everything worked out (and you used the example table we created above), your app should look like this: diff --git a/content/kb/tutorials/databases/tigergraph.md b/content/kb/tutorials/databases/tigergraph.md index c8d90c7f8..acb56b363 100644 --- a/content/kb/tutorials/databases/tigergraph.md +++ b/content/kb/tutorials/databases/tigergraph.md @@ -1,13 +1,13 @@ --- title: Connect Streamlit to TigerGraph -slug: /knowledge-base/tutorials/databases/tigergraph +slug: /develop/tutorials/databases/tigergraph --- # Connect Streamlit to TigerGraph ## Introduction -This guide explains how to securely access a TigerGraph database from Streamlit Community Cloud. It uses the [pyTigerGraph](https://pytigergraph.github.io/pyTigerGraph/GettingStarted/) library and Streamlit's [Secrets management](/streamlit-community-cloud/deploy-your-app/secrets-management). +This guide explains how to securely access a TigerGraph database from Streamlit Community Cloud. It uses the [pyTigerGraph](https://pytigergraph.github.io/pyTigerGraph/GettingStarted/) library and Streamlit's [Secrets management](/deploy/streamlit-community-cloud/deploy-your-app/secrets-management). ## Create a TigerGraph Cloud Database @@ -43,7 +43,7 @@ Add this file to `.gitignore` and don't commit it to your GitHub repo! ## Copy your app secrets to the cloud -As the `secrets.toml` file above is not committed to GitHub, you need to pass its content to your deployed app (on Streamlit Community Cloud) separately. Go to the [app dashboard](https://share.streamlit.io/) and in the app's dropdown menu, click on Edit Secrets. Copy the content of `secrets.toml` into the text area. More information is available at [Secrets management](/streamlit-community-cloud/deploy-your-app/secrets-management). +As the `secrets.toml` file above is not committed to GitHub, you need to pass its content to your deployed app (on Streamlit Community Cloud) separately. Go to the [app dashboard](https://share.streamlit.io/) and in the app's dropdown menu, click on Edit Secrets. Copy the content of `secrets.toml` into the text area. More information is available at [Secrets management](/deploy/streamlit-community-cloud/deploy-your-app/secrets-management). ![Secrets manager screenshot](/images/databases/edit-secrets.png) @@ -85,7 +85,7 @@ for key, val in items[1].items(): st.write(f"Patient {items[0]}'s {key} is {val}.") ``` -See `st.cache_data` above? Without it, Streamlit would run the query every time the app reruns (e.g. on a widget interaction). With `st.cache_data`, it only runs when the query changes or after 10 minutes (that's what `ttl` is for). Watch out: If your database updates more frequently, you should adapt `ttl` or remove caching so viewers always see the latest data. Learn more in [Caching](/library/advanced-features/caching). +See `st.cache_data` above? Without it, Streamlit would run the query every time the app reruns (e.g. on a widget interaction). With `st.cache_data`, it only runs when the query changes or after 10 minutes (that's what `ttl` is for). Watch out: If your database updates more frequently, you should adapt `ttl` or remove caching so viewers always see the latest data. Learn more in [Caching](/develop/concepts/architecture/caching). If everything worked out (and you used the example data we created above), your app should look like this: diff --git a/content/kb/tutorials/deploy/index.md b/content/kb/tutorials/deploy/_index.md similarity index 86% rename from content/kb/tutorials/deploy/index.md rename to content/kb/tutorials/deploy/_index.md index 7e7fac0d1..fc698d394 100644 --- a/content/kb/tutorials/deploy/index.md +++ b/content/kb/tutorials/deploy/_index.md @@ -1,14 +1,14 @@ --- -title: Deploy Streamlit apps -slug: /knowledge-base/tutorials/deploy +title: Deployment tutorials +slug: /deploy/tutorials --- -# Deploy Streamlit apps +# Deployment tutorials This sections contains step-by-step guides on how to deploy Streamlit apps to various cloud platforms and services. We have deployment guides for: - + screenshot @@ -16,7 +16,7 @@ This sections contains step-by-step guides on how to deploy Streamlit apps to va - + screenshot @@ -24,7 +24,7 @@ This sections contains step-by-step guides on how to deploy Streamlit apps to va - + screenshot diff --git a/content/kb/tutorials/deploy/docker.md b/content/kb/tutorials/deploy/docker.md index ba184a534..3af0b38ef 100644 --- a/content/kb/tutorials/deploy/docker.md +++ b/content/kb/tutorials/deploy/docker.md @@ -1,6 +1,6 @@ --- title: Deploy Streamlit using Docker -slug: /knowledge-base/tutorials/deploy/docker +slug: /deploy/tutorials/docker --- # Deploy Streamlit using Docker @@ -12,7 +12,7 @@ So you have an amazing app and you want to start sharing it with other people, w - **On your corporate network** - Most corporate networks are closed to the outside world. You typically use a VPN to log onto your corporate network and access resources there. You could run your Streamlit app on a server in your corporate network for security reasons, to ensure that only folks internal to your company can access it. - **On the cloud** - If you'd like to access your Streamlit app from outside of a corporate network, or share your app with folks outside of your home network or laptop, you might choose this option. In this case, it'll depend on your hosting provider. We have [community-submitted guides](/knowledge-base/deploy/deploy-streamlit-heroku-aws-google-cloud) from Heroku, AWS, and other providers. -Wherever you decide to deploy your app, you will first need to containerize it. This guide walks you through using Docker to deploy your app. If you prefer Kubernetes see [Deploy Streamlit using Kubernetes](/knowledge-base/tutorials/deploy/kubernetes). +Wherever you decide to deploy your app, you will first need to containerize it. This guide walks you through using Docker to deploy your app. If you prefer Kubernetes see [Deploy Streamlit using Kubernetes](/deploy/tutorials/kubernetes). ## Prerequisites @@ -131,7 +131,7 @@ Let’s walk through each line of the Dockerfile : - streamlit_app.py ``` - where `requirements.txt` file contains all your [Python dependencies](https://docs.streamlit.io/streamlit-community-cloud/deploy-your-app/app-dependencies#add-python-dependencies). E.g + where `requirements.txt` file contains all your [Python dependencies](https://docs.streamlit.io/deploy/streamlit-community-cloud/deploy-your-app/app-dependencies#add-python-dependencies). E.g ``` altair @@ -191,7 +191,7 @@ Let’s walk through each line of the Dockerfile : More generally, the idea is copy your app code from wherever it may live on your server into the container. If the code is not in the same directory as the Dockerfile, modify the above command to include the path to the code. -5. Install your app’s [Python dependencies](/streamlit-community-cloud/deploy-your-app/app-dependencies#add-python-dependencies) from the cloned `requirements.txt` in the container: +5. Install your app’s [Python dependencies](/deploy/streamlit-community-cloud/deploy-your-app/app-dependencies#add-python-dependencies) from the cloned `requirements.txt` in the container: ```docker RUN pip3 install -r requirements.txt diff --git a/content/kb/tutorials/deploy/kubernetes.md b/content/kb/tutorials/deploy/kubernetes.md index d2c7109c6..8c347dc39 100644 --- a/content/kb/tutorials/deploy/kubernetes.md +++ b/content/kb/tutorials/deploy/kubernetes.md @@ -1,6 +1,6 @@ --- title: Deploy Streamlit using Kubernetes -slug: /knowledge-base/tutorials/deploy/kubernetes +slug: /deploy/tutorials/kubernetes --- # Deploy Streamlit using Kubernetes @@ -12,7 +12,7 @@ So you have an amazing app and you want to start sharing it with other people, w - **On your corporate network** - Most corporate networks are closed to the outside world. You typically use a VPN to log onto your corporate network and access resources there. You could run your Streamlit app on a server in your corporate network for security reasons, to ensure that only folks internal to your company can access it. - **On the cloud** - If you'd like to access your Streamlit app from outside of a corporate network, or share your app with folks outside of your home network or laptop, you might choose this option. In this case, it'll depend on your hosting provider. We have [community-submitted guides](/knowledge-base/deploy/deploy-streamlit-heroku-aws-google-cloud) from Heroku, AWS, and other providers. -Wherever you decide to deploy your app, you will first need to containerize it. This guide walks you through using Kubernetes to deploy your app. If you prefer Docker see [Deploy Streamlit using Docker](/knowledge-base/tutorials/deploy/docker). +Wherever you decide to deploy your app, you will first need to containerize it. This guide walks you through using Kubernetes to deploy your app. If you prefer Docker see [Deploy Streamlit using Docker](/deploy/tutorials/docker). ## Prerequisites diff --git a/content/kb/tutorials/index.md b/content/kb/tutorials/index.md deleted file mode 100644 index 15dc83425..000000000 --- a/content/kb/tutorials/index.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -title: Tutorials -slug: /knowledge-base/tutorials ---- - -# Tutorials - -Our tutorials include step-by-step examples of building different types of apps in Streamlit. - -- [Connect to data sources](/knowledge-base/tutorials/databases) -- [Deploy Streamlit apps](/knowledge-base/tutorials/deploy) -- [Build a basic LLM chat app](/knowledge-base/tutorials/build-conversational-apps) -- [Build an LLM app using LangChain](/knowledge-base/tutorials/llm-quickstart) diff --git a/content/kb/tutorials/llm/index.md b/content/kb/tutorials/llm/_index.md similarity index 99% rename from content/kb/tutorials/llm/index.md rename to content/kb/tutorials/llm/_index.md index 74e810183..f5f51416d 100644 --- a/content/kb/tutorials/llm/index.md +++ b/content/kb/tutorials/llm/_index.md @@ -1,6 +1,6 @@ --- title: Build an LLM app using LangChain -slug: /knowledge-base/tutorials/llm-quickstart +slug: /develop/tutorials/llms/llm-quickstart --- # Build an LLM app using LangChain diff --git a/content/kb/using-streamlit/index.md b/content/kb/using-streamlit/_index.md similarity index 81% rename from content/kb/using-streamlit/index.md rename to content/kb/using-streamlit/_index.md index 740a484c7..d8de39157 100644 --- a/content/kb/using-streamlit/index.md +++ b/content/kb/using-streamlit/_index.md @@ -1,17 +1,15 @@ --- -title: Using Streamlit +title: FAQ slug: /knowledge-base/using-streamlit --- -# Using Streamlit +# FAQ Here are some frequently asked questions about using Streamlit. If you feel something important is missing that everyone needs to know, please [open an issue](https://github.com/streamlit/docs/issues) or [submit a pull request](https://github.com/streamlit/docs/pulls) and we'll be happy to review it! - [Sanity checks](/knowledge-base/using-streamlit/sanity-checks) -- [How do I run my Streamlit script?](/knowledge-base/using-streamlit/how-do-i-run-my-streamlit-script) - [How can I make Streamlit watch for changes in other modules I'm importing in my app?](/knowledge-base/using-streamlit/streamlit-watch-changes-other-modules-importing-app) - [What browsers does Streamlit support?](/knowledge-base/using-streamlit/supported-browsers) -- [What is the path of Streamlit’s `config.toml` file?](/knowledge-base/using-streamlit/path-streamlit-config-toml) - [Where does st.file_uploader store uploaded files and when do they get deleted?](/knowledge-base/using-streamlit/where-file-uploader-store-when-deleted) - [How do you retrieve the filename of a file uploaded with st.file_uploader?](/knowledge-base/using-streamlit/retrieve-filename-uploaded) - [How to remove "· Streamlit" from the app title?](/knowledge-base/using-streamlit/remove-streamlit-app-title) @@ -20,12 +18,9 @@ Here are some frequently asked questions about using Streamlit. If you feel some - [How do I get dataframe row-selections from a user?](/knowledge-base/using-streamlit/how-to-get-row-selections) - [How can I make `st.pydeck_chart` use custom Mapbox styles?](/knowledge-base/using-streamlit/pydeck-chart-custom-mapbox-styles) - [How to insert elements out of order?](/knowledge-base/using-streamlit/insert-elements-out-of-order) -- [How to animate elements?](/knowledge-base/using-streamlit/animate-elements) -- [Append data to a table or chart](/knowledge-base/using-streamlit/append-data-table-chart) - [How do I upgrade to the latest version of Streamlit?](/knowledge-base/using-streamlit/how-upgrade-latest-version-streamlit) - [Widget updating for every second input when using session state](/knowledge-base/using-streamlit/widget-updating-session-state) - [How do I create an anchor link?](/knowledge-base/using-streamlit/create-anchor-link) - [How do I enable camera access?](/knowledge-base/using-streamlit/enable-camera) - [Why does Streamlit restrict nested `st.columns`?](/knowledge-base/using-streamlit/why-streamlit-restrict-nested-columns) -- [How to host static files in Streamlit?](/library/advanced-features/static-file-serving) - [What is serializable session state?](/knowledge-base/using-streamlit/serializable-session-state) diff --git a/content/kb/using-streamlit/animate-elements.md b/content/kb/using-streamlit/animate-elements.md deleted file mode 100644 index e0ef98e3d..000000000 --- a/content/kb/using-streamlit/animate-elements.md +++ /dev/null @@ -1,34 +0,0 @@ ---- -title: How to animate elements? -slug: /knowledge-base/using-streamlit/animate-elements ---- - -# How to animate elements? - -Let's combine some of the things you've learned to create compelling -animations in your app. - -```python -progress_bar = st.progress(0) -status_text = st.empty() -chart = st.line_chart(np.random.randn(10, 2)) - -for i in range(100): - # Update progress bar. - progress_bar.progress(i + 1) - - new_rows = np.random.randn(10, 2) - - # Update status text. - status_text.text( - 'The latest random number is: %s' % new_rows[-1, 1]) - - # Append data to the chart. - chart.add_rows(new_rows) - - # Pretend we're doing some computation that takes time. - time.sleep(0.1) - -status_text.text('Done!') -st.balloons() -``` diff --git a/content/kb/using-streamlit/append-data-table-chart.md b/content/kb/using-streamlit/append-data-table-chart.md deleted file mode 100644 index b75602e7d..000000000 --- a/content/kb/using-streamlit/append-data-table-chart.md +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: Append data to a table or chart -slug: /knowledge-base/using-streamlit/append-data-table-chart ---- - -# Append data to a table or chart - -In Streamlit, you can not only replace entire elements in your app, but also -modify the data behind those elements. Here is how: - -```python -import numpy as np -import time - -# Get some data. -data = np.random.randn(10, 2) - -# Show the data as a chart. -chart = st.line_chart(data) - -# Wait 1 second, so the change is clearer. -time.sleep(1) - -# Grab some more data. -data2 = np.random.randn(10, 2) - -# Append the new data to the existing chart. -chart.add_rows(data2) -``` diff --git a/content/kb/using-streamlit/create-anchor-link.md b/content/kb/using-streamlit/create-anchor-link.md index ef5099974..7bae15b33 100644 --- a/content/kb/using-streamlit/create-anchor-link.md +++ b/content/kb/using-streamlit/create-anchor-link.md @@ -13,7 +13,7 @@ Have you wanted to create anchors so that users of your app can directly navigat Anchors are automatically added to header text. -For example, if you define a header text via the [st.header()](/library/api-reference/text/st.header) command as follows: +For example, if you define a header text via the [st.header()](/develop/api-reference/text/st.header) command as follows: ```python st.header("Section 1") diff --git a/content/kb/using-streamlit/how-download-file-streamlit.md b/content/kb/using-streamlit/how-download-file-streamlit.md index 15998beca..ec4fd7e83 100644 --- a/content/kb/using-streamlit/how-download-file-streamlit.md +++ b/content/kb/using-streamlit/how-download-file-streamlit.md @@ -5,7 +5,7 @@ slug: /knowledge-base/using-streamlit/how-download-file-streamlit # How to download a file in Streamlit? -Use the [`st.download_button`](/library/api-reference/widgets/st.download_button) widget that is natively built into Streamlit. Check out a [sample app](https://streamlit-release-demos-0-88streamlit-app-0-88-v8ram3.streamlit.app/) demonstrating how you can use `st.download_button` to download common file formats. +Use the [`st.download_button`](/develop/api-reference/widgets/st.download_button) widget that is natively built into Streamlit. Check out a [sample app](https://streamlit-release-demos-0-88streamlit-app-0-88-v8ram3.streamlit.app/) demonstrating how you can use `st.download_button` to download common file formats. ## Example usage @@ -51,4 +51,4 @@ Additional resources: - [https://blog.streamlit.io/0-88-0-release-notes/](https://blog.streamlit.io/0-88-0-release-notes/) - [https://streamlit-release-demos-0-88streamlit-app-0-88-v8ram3.streamlit.app/](https://streamlit-release-demos-0-88streamlit-app-0-88-v8ram3.streamlit.app/) -- [https://docs.streamlit.io/library/api-reference/widgets/st.download_button](https://docs.streamlit.io/library/api-reference/widgets/st.download_button) +- [https://docs.streamlit.io/develop/api-reference/widgets/st.download_button](https://docs.streamlit.io/develop/api-reference/widgets/st.download_button) diff --git a/content/kb/using-streamlit/how-download-pandas-dataframe-csv.md b/content/kb/using-streamlit/how-download-pandas-dataframe-csv.md index f8e28fa32..96034e168 100644 --- a/content/kb/using-streamlit/how-download-pandas-dataframe-csv.md +++ b/content/kb/using-streamlit/how-download-pandas-dataframe-csv.md @@ -5,7 +5,7 @@ slug: /knowledge-base/using-streamlit/how-download-pandas-dataframe-csv # How to download a Pandas DataFrame as a CSV? -Use the [`st.download_button`](/library/api-reference/widgets/st.download_button) widget that is natively built into Streamlit. Check out a [sample app](https://streamlit-release-demos-0-88streamlit-app-0-88-v8ram3.streamlit.app/) demonstrating how you can use `st.download_button` to download common file formats. +Use the [`st.download_button`](/develop/api-reference/widgets/st.download_button) widget that is natively built into Streamlit. Check out a [sample app](https://streamlit-release-demos-0-88streamlit-app-0-88-v8ram3.streamlit.app/) demonstrating how you can use `st.download_button` to download common file formats. ## Example usage @@ -35,4 +35,4 @@ Additional resources: - [https://blog.streamlit.io/0-88-0-release-notes/](https://blog.streamlit.io/0-88-0-release-notes/) - [https://streamlit-release-demos-0-88streamlit-app-0-88-v8ram3.streamlit.app/](https://streamlit-release-demos-0-88streamlit-app-0-88-v8ram3.streamlit.app/) -- [https://docs.streamlit.io/library/api-reference/widgets/st.download_button](https://docs.streamlit.io/library/api-reference/widgets/st.download_button) +- [https://docs.streamlit.io/develop/api-reference/widgets/st.download_button](https://docs.streamlit.io/develop/api-reference/widgets/st.download_button) diff --git a/content/kb/using-streamlit/how-run-my-streamlit-script.md b/content/kb/using-streamlit/how-run-my-streamlit-script.md index da93cbe78..f5474624b 100644 --- a/content/kb/using-streamlit/how-run-my-streamlit-script.md +++ b/content/kb/using-streamlit/how-run-my-streamlit-script.md @@ -1,9 +1,9 @@ --- -title: How do I run my Streamlit script? -slug: /knowledge-base/using-streamlit/how-do-i-run-my-streamlit-script +title: Run your Streamlit script +slug: /develop/concepts/architecture/run-your-app --- -# How do I run my Streamlit script? +# Run your Streamlit script Working with Streamlit is simple. First you sprinkle a few Streamlit commands into a normal Python script, and then you run it. We list few ways to run your script, depending on your use case. diff --git a/content/kb/using-streamlit/how-to-get-row-selections.md b/content/kb/using-streamlit/how-to-get-row-selections.md index c8cc9cd91..5c6f78080 100644 --- a/content/kb/using-streamlit/how-to-get-row-selections.md +++ b/content/kb/using-streamlit/how-to-get-row-selections.md @@ -5,7 +5,7 @@ slug: /knowledge-base/using-streamlit/how-to-get-row-selections # How do I get dataframe row-selections from a user? -At the moment, [`st.dataframe`](/api-reference/data/st.dataframe) and [`st.data_editor`](/library/api-reference/data/st.data_editor) do not natively support passing user-selected rows to the Python backend. We are working to support this in the future. For now, if you need to get row-selections from a user, you can accomplish this by adding an extra [Checkbox column](/library/api-reference/data/st.column_config/st.column_config.checkboxcolumn)) to your dataframe and using `st.data_editor`. You can use this extra column to collect a user's selection(s). +At the moment, [`st.dataframe`](/api-reference/data/st.dataframe) and [`st.data_editor`](/develop/api-reference/data/st.data_editor) do not natively support passing user-selected rows to the Python backend. We are working to support this in the future. For now, if you need to get row-selections from a user, you can accomplish this by adding an extra [Checkbox column](/develop/api-reference/data/st.column_config/st.column_config.checkboxcolumn)) to your dataframe and using `st.data_editor`. You can use this extra column to collect a user's selection(s). ## Example diff --git a/content/kb/using-streamlit/insert-elements-out-of-order.md b/content/kb/using-streamlit/insert-elements-out-of-order.md index 4c9a1aadf..9bd60d8bb 100644 --- a/content/kb/using-streamlit/insert-elements-out-of-order.md +++ b/content/kb/using-streamlit/insert-elements-out-of-order.md @@ -5,7 +5,7 @@ slug: /knowledge-base/using-streamlit/insert-elements-out-of-order # How to insert elements out of order? -You can use the [`st.empty`](/library/api-reference/layout/st.empty) method as a placeholder, +You can use the [`st.empty`](/develop/api-reference/layout/st.empty) method as a placeholder, to "save" a slot in your app that you can use later. ```python diff --git a/content/kb/using-streamlit/path-streamlit-config-toml.md b/content/kb/using-streamlit/path-streamlit-config-toml.md deleted file mode 100644 index 8b19fefdf..000000000 --- a/content/kb/using-streamlit/path-streamlit-config-toml.md +++ /dev/null @@ -1,12 +0,0 @@ ---- -title: What is the path of Streamlit’s config.toml file? -slug: /knowledge-base/using-streamlit/path-streamlit-config-toml ---- - -# What is the path of Streamlit’s config.toml file? - -A global config file is found at `~/.streamlit/config.toml` for macOS/Linux or `%userprofile%/.streamlit/config.toml` for Windows. - -A per-project config file can be created at `$CWD/.streamlit/config.toml`, where `$CWD` is the folder you’re running Streamlit from. - -Click [here](/library/advanced-features/configuration) to learn more about Streamlit configuration options. diff --git a/content/kb/using-streamlit/remove-streamlit-app-title.md b/content/kb/using-streamlit/remove-streamlit-app-title.md index d36d1eab3..8d2a6f7e7 100644 --- a/content/kb/using-streamlit/remove-streamlit-app-title.md +++ b/content/kb/using-streamlit/remove-streamlit-app-title.md @@ -5,7 +5,7 @@ slug: /knowledge-base/using-streamlit/remove-streamlit-app-title # How to remove "· Streamlit" from the app title? -Using [`st.set_page_config`](/library/api-reference/utilities/st.set_page_config) to assign the page title will not append "· Streamlit" to that title. E.g.: +Using [`st.set_page_config`](/develop/api-reference/configuration/st.set_page_config) to assign the page title will not append "· Streamlit" to that title. E.g.: ```python import streamlit as st diff --git a/content/kb/using-streamlit/sanity-checks.md b/content/kb/using-streamlit/sanity-checks.md index a540be79b..e9ec3cbfa 100644 --- a/content/kb/using-streamlit/sanity-checks.md +++ b/content/kb/using-streamlit/sanity-checks.md @@ -84,7 +84,7 @@ pip install --upgrade streamlit==1.0.0 ``` ...where `1.0.0` is the version you'd like to downgrade to. See -[Changelog](/library/changelog) for a complete list of Streamlit versions. +[Changelog](/develop/quick-reference/changelog) for a complete list of Streamlit versions. ## Check #6 [Windows]: Is Python added to your PATH? diff --git a/content/kb/using-streamlit/serializable-session-state.md b/content/kb/using-streamlit/serializable-session-state.md index 047194b60..6233ca7d2 100644 --- a/content/kb/using-streamlit/serializable-session-state.md +++ b/content/kb/using-streamlit/serializable-session-state.md @@ -7,11 +7,11 @@ slug: /knowledge-base/using-streamlit/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](https://docs.python.org/3/library/pickle.html) module serializes Python objects to a byte stream ("pickling") and deserializes the stream into an object ("unpickling"). +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](https://docs.python.org/3/develop/pickle.html) module serializes Python objects to a byte stream ("pickling") and deserializes the stream into an object ("unpickling"). -By default, Streamlit’s [Session State](/library/advanced-features/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](https://docs.python.org/3/reference/expressions.html#lambda) 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. +By default, Streamlit’s [Session State](/develop/concepts/architecture/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](https://docs.python.org/3/reference/expressions.html#lambda) 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](https://docs.streamlit.io/library/advanced-features/configuration) 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: +To that end, Streamlit provides a `runner.enforceSerializableSessionState` [configuration option](https://docs.streamlit.io/develop/concepts/configuration) 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: ```toml # .streamlit/config.toml @@ -19,7 +19,7 @@ To that end, Streamlit provides a `runner.enforceSerializableSessionState` [conf enforceSerializableSessionState = true ``` -By "_pickle-serializable_", we mean calling `pickle.dumps(obj)` should not raise a [`PicklingError`](https://docs.python.org/3/library/pickle.html#pickle.PicklingError) exception. When the config option is enabled, adding unserializable data to session state should result in an exception. E.g., +By "_pickle-serializable_", we mean calling `pickle.dumps(obj)` should not raise a [`PicklingError`](https://docs.python.org/3/develop/pickle.html#pickle.PicklingError) exception. When the config option is enabled, adding unserializable data to session state should result in an exception. E.g., ```python import streamlit as st diff --git a/content/kb/using-streamlit/where-file-uploader-store-when-deleted.md b/content/kb/using-streamlit/where-file-uploader-store-when-deleted.md index 195ff699b..29e80964c 100644 --- a/content/kb/using-streamlit/where-file-uploader-store-when-deleted.md +++ b/content/kb/using-streamlit/where-file-uploader-store-when-deleted.md @@ -5,7 +5,7 @@ slug: /knowledge-base/using-streamlit/where-file-uploader-store-when-deleted # Where does st.file_uploader store uploaded files and when do they get deleted? -When you upload a file using [`st.file_uploader`](/library/api-reference/widgets/st.file_uploader), the data are copied to the Streamlit backend via the browser, and contained in a BytesIO buffer in Python memory (i.e. RAM, not disk). The data will persist in RAM until the Streamlit app re-runs from top-to-bottom, which is on each widget interaction. If you need to save the data that was uploaded between runs, then you can [cache](/library/advanced-features/caching) it so that Streamlit persists it across re-runs. +When you upload a file using [`st.file_uploader`](/develop/api-reference/widgets/st.file_uploader), the data are copied to the Streamlit backend via the browser, and contained in a BytesIO buffer in Python memory (i.e. RAM, not disk). The data will persist in RAM until the Streamlit app re-runs from top-to-bottom, which is on each widget interaction. If you need to save the data that was uploaded between runs, then you can [cache](/develop/concepts/architecture/caching) it so that Streamlit persists it across re-runs. As files are stored in memory, they get deleted immediately as soon as they’re not needed anymore. diff --git a/content/kb/using-streamlit/why-streamlit-restrict-nested-columns.md b/content/kb/using-streamlit/why-streamlit-restrict-nested-columns.md index 04ba7204a..8c96c0dff 100644 --- a/content/kb/using-streamlit/why-streamlit-restrict-nested-columns.md +++ b/content/kb/using-streamlit/why-streamlit-restrict-nested-columns.md @@ -5,7 +5,7 @@ slug: /knowledge-base/using-streamlit/why-streamlit-restrict-nested-columns # Why does Streamlit restrict nested `st.columns`? -Starting in version 1.18.0, Streamlit allows nesting [`st.columns`](/library/api-reference/layout/st.columns) inside other +Starting in version 1.18.0, Streamlit allows nesting [`st.columns`](/develop/api-reference/layout/st.columns) inside other `st.columns` with the following restrictions: - In the main area of the app, columns can be nested up to one level of nesting. diff --git a/content/kb/using-streamlit/widget-updating-session-state.md b/content/kb/using-streamlit/widget-updating-session-state.md index 3a571e8da..473f25159 100644 --- a/content/kb/using-streamlit/widget-updating-session-state.md +++ b/content/kb/using-streamlit/widget-updating-session-state.md @@ -7,7 +7,7 @@ slug: /knowledge-base/using-streamlit/widget-updating-session-state ## Overview -You are using [session state](/library/api-reference/session-state) to store page interactions in your app. When users interact with a widget in your app (e.g., click a button), you expect your app to update its widget states and reflect the new values. However, you notice that it doesn't. Instead, users have to interact with the widget twice (e.g., click a button twice) for the app to show the correct values. What do you do now? 🤔 Let's walk through the solution in the section below. +You are using [session state](/develop/api-reference/caching-and-state/st.session_state) to store page interactions in your app. When users interact with a widget in your app (e.g., click a button), you expect your app to update its widget states and reflect the new values. However, you notice that it doesn't. Instead, users have to interact with the widget twice (e.g., click a button twice) for the app to show the correct values. What do you do now? 🤔 Let's walk through the solution in the section below. ## Solution @@ -15,7 +15,7 @@ When using session state to update widgets or values in your script, you need to Let's see this in an example. Say you want a user to click a button that resets a slider. -To have the slider's value update on the button click, you need to use a [callback function](/library/api-reference/session-state#use-callbacks-to-update-session-state) with the `on_click` parameter of [`st.button`](/library/api-reference/widgets/st.button): +To have the slider's value update on the button click, you need to use a [callback function](/develop/api-reference/caching-and-state/st.session_state#use-callbacks-to-update-session-state) with the `on_click` parameter of [`st.button`](/develop/api-reference/widgets/st.button): ```python # the callback function for the button will add 1 to the diff --git a/content/library/_index.md b/content/library/_index.md new file mode 100644 index 000000000..25f97b3bd --- /dev/null +++ b/content/library/_index.md @@ -0,0 +1,35 @@ +--- +title: Develop +slug: /develop +--- + +# Develop + +Get all the information you need to build beautiful, performant web apps with Streamlit! + + + Learn how Streamlit works with in-depth guides to our execution model and features. + Learn about our API with function definitions and examples. + Security first! If you want to read up on how we handle your data before you get started, we've got you covered. + Check out our quick references for easy access to convenient information like our changelog, cheat sheet, pre-release features, and roadmap. + diff --git a/content/library/advanced-features/_advanced-features.md b/content/library/advanced-features/_advanced-features.md deleted file mode 100644 index 7507301a8..000000000 --- a/content/library/advanced-features/_advanced-features.md +++ /dev/null @@ -1,148 +0,0 @@ ---- -title: Advanced features -slug: /library/advanced-features ---- - -## Advanced features - -This section gives you background on how different parts of Streamlit work. - - - - - -
    ⋮ App menu
    - -Streamlit provides a configurable menu within your app to access convenient tools for developers and viewers. These options can modify the appearance of your app while running. - -- [Modify your app's theme while running](/library/advanced-features/app-menu#settings) -- [Record a screencast of your app](/library/advanced-features/app-menu#record-a-screencast) -- [Deploy a local app to Streamlit Community Cloud](/library/advanced-features/app-menu#deploy-this-app) -- [Customize or hide the app menu](/library/advanced-features/app-menu#customize-the-menu) - -
    - - - -
    Command-line options
    - -When you install Streamlit, a command-line (CLI) tool gets installed as well. The purpose of this tool is to run Streamlit apps, change Streamlit configuration options, and help you diagnose and fix issues. - -- [What is the command-line interface (CLI)?](/library/advanced-features/cli#command-line-interface) -- [How to run Streamlit apps from the CLI?](/library/advanced-features/cli#run-streamlit-apps) -- [View Streamlit version from the CLI?](/library/advanced-features/cli#view-streamlit-version) -- [View documentation from the CLI](/library/advanced-features/cli#view-documentation) -- [Clear cache from the CLI](/library/advanced-features/cli#clear-cache) - -
    - - - -
    Streamlit configuration
    - -Streamlit provides four different ways to set configuration options. Learn how to use each of them to change the behavior of Streamlit. - -- [How to set configuration options?](/library/advanced-features/configuration) -- [Opt out of telemetry collection](/library/advanced-features/configuration#telemetry) -- [View all configuration options](/library/advanced-features/configuration#view-all-configuration-options) - -
    - - - -
    Theming
    - -This section provides examples of how Streamlit page elements are affected by the various theme config options. - -- [primaryColor](/library/advanced-features/theming#primarycolor) -- [backgroundcolor](/library/advanced-features/theming#backgroundcolor) -- [secondarybackgroundcolor](/library/advanced-features/theming#secondarybackgroundcolor) -- [textcolor](/library/advanced-features/theming#textcolor) -- [font](/library/advanced-features/theming#font) -- [base](/library/advanced-features/theming#base) - -
    - - - -
    Caching
    - -The Streamlit cache allows your app to stay performant even when loading data from the web, manipulating large datasets, or performing expensive computations. To cache a function in Streamlit, you need to decorate it with one of two decorators: `st.cache_data` and `st.cache_resource`. - -- [Minimal example](/library/advanced-features/caching#minimal-example) -- [Basic usage](/library/advanced-features/caching#basic-usage) - - [st.cache_data](/library/advanced-features/caching#stcache_data) - - [st.cache_resource](/library/advanced-features/caching#stcache_resource) - - [Deciding which caching decorator to use](/library/advanced-features/caching#deciding-which-caching-decorator-to-use) -- [Advanced usage](/library/advanced-features/caching#advanced-usage) - - [Excluding input parameters](/library/advanced-features/caching#excluding-input-parameters) - - [Controlling cache size and duration](/library/advanced-features/caching#controlling-cache-size-and-duration) - - [Customizing the spinner](/library/advanced-features/caching#customizing-the-spinner) - - [Using Streamlit commands in cached functions](/library/advanced-features/caching#using-streamlit-commands-in-cached-functions) - - [Mutation and concurrency issues](/library/advanced-features/caching#mutation-and-concurrency-issues) -- [Migrating from st.cache](/library/advanced-features/caching#migrating-from-stcache) - -
    - - - -
    Add statefulness to apps
    - -Session State is a way to share variables between reruns, for each user session. In addition to the ability to store and persist state, Streamlit also exposes the ability to manipulate state using Callbacks. - -- [What is Session State?](/library/advanced-features/session-state#what-is-state) -- [How to initialize Session State items?](/library/advanced-features/session-state#initialization) -- [How to read and update Session State items?](/library/advanced-features/session-state#reads-and-updates) -- [How to use callbacks in Session State?](/library/advanced-features/session-state#example-2-session-state-and-callbacks) -- [How to use `args` and `kwargs` in callbacks?](/library/advanced-features/session-state#example-3-use-args-and-kwargs-in-callbacks) -- [How to use callbacks in forms?](/library/advanced-features/session-state#example-4-forms-and-callbacks) -- [How is Session State related to Widget State?](/library/advanced-features/session-state#session-state-and-widget-state-association) -- [Caveats and limitations](/library/advanced-features/session-state#caveats-and-limitations) - -
    - - - -
    Pre-release features
    - -At Streamlit, we like to move quick while keeping things stable. In our latest effort to move even faster without sacrificing stability, we're offering our bold and fearless users two ways to try out Streamlit's bleeding-edge features. - -- [Experimental features](/library/advanced-features/prerelease#experimental-features) -- [Nightly releases](/library/advanced-features/prerelease#nightly-releases) - -
    - - - -
    Secrets management
    - -This section provides examples of how to use secrets management to store and retrieve sensitive information in your Streamlit app. - -- [Develop locally and set up secrets](/library/advanced-features/secrets-management#develop-locally-and-set-up-secrets) -- [Use secrets in your app](/library/advanced-features/secrets-management#use-secrets-in-your-app) -- [Error handling](/library/advanced-features/secrets-management#error-handling) -- [Use secrets on Streamlit Community Cloud](/library/advanced-features/secrets-management#use-secrets-on-streamlit-community-cloud) - -
    - - - -
    Working with timezones
    - -Working with timezones can be tricky. This section provides a high-level description of how to handle timezones in Streamlit to avoid unexpected behavior. - -- [Overview](/library/advanced-features/timezone-handling#working-with-timezones) -- [How Streamlit handles timezones](/library/advanced-features/timezone-handling#how-streamlit-handles-timezones) -- [`datetime` instance without a timezone (naive)](/library/advanced-features/timezone-handling#datetime-instance-without-a-timezone-naive) -- [`datetime` instance with a timezone](/library/advanced-features/timezone-handling#datetime-instance-with-a-timezone) - -
    - - - -
    Advanced notes on widget behavior
    - -Widgets are magical and often work how you want. But they can have surprising behavior in some situations. This section provides is a high-level, abstract description of widget behavior, including some common edge-cases. - -
    -
    diff --git a/content/library/advanced-features/_index.md b/content/library/advanced-features/_index.md new file mode 100644 index 000000000..76562bbbd --- /dev/null +++ b/content/library/advanced-features/_index.md @@ -0,0 +1,82 @@ +--- +title: Development concepts +slug: /develop/concepts +--- + +# Development concepts + +This section gives you background on how different parts of Streamlit work. + + + + + +
    Streamlit's architecture and execution model
    + +Streamlit's execution model makes it easy to turn your scripts into beautiful, interactive web apps. + +- Understand how to run your app. +- Understand Streamlit's execution and server-client model. +- Understand the primary tools to work with Streamlit reruns. + +
    + + + +
    Multipage apps
    + +Streamlit provides an automated way to build multipage apps through directory structure. + +- Learn how to structure and configure your multipage app. + +
    + + + +
    App design considerations
    + +Bring together Streamlit's architecture and execution model to design your app. Work with Streamlit commands to render dynamic and +interactic content for your users. + +- Learn how to make your apps performant and easy-to-manage. +- Learn how to structure and design your project. + +
    + + + +
    Connections and secrets
    + +- Learn how to manage connections and secrets with Streamlit's convenient, built-in features. + +
    + + + +
    Creating custom components
    + +Custom components extend Streamlit's functionality. + +- Learn how to build your own custom component. +- Learn how install a third-party component. + +
    + + + +
    Configuration and theming
    + +Streamlit provides a variety options to customize and configure your app. + +- Learn how to work with configuration options, including server settings, client settings, and theming. + +
    + + + +
    App testing
    + +Streamlit app testing enables developers to build and run automated tests. Bring your favorite test automation software and enjoy simple syntax to simulate user input and inspect rendered output. + +
    +
    diff --git a/content/library/advanced-features/advanced-widget-behavior.md b/content/library/advanced-features/advanced-widget-behavior.md index 4af3bb5fb..5ef17bd97 100644 --- a/content/library/advanced-features/advanced-widget-behavior.md +++ b/content/library/advanced-features/advanced-widget-behavior.md @@ -1,13 +1,13 @@ --- title: Widget behavior -slug: /library/advanced-features/widget-behavior +slug: /develop/concepts/architecture/widget-behavior --- # Understanding widget behavior Widgets (like `st.button`, `st.selectbox`, and `st.text_input`) are at the heart of Streamlit apps. They are the interactive elements of Streamlit that pass information from your users into your Python code. Widgets are magical and often work how you want, but they can have surprising behavior in some situations. Understanding the different parts of a widget and the precise order in which events occur helps you achieve your desired results. -This guide covers advanced concepts about widgets. Generally, it begins with simpler concepts and increases in complexity. For most beginning users, these details won't be important to know right away. When you want to dynamically change widgets or preserve widget information between pages, these concepts will be important to understand. We recommend having a basic understanding of [Session State](/library/api-reference/session-state) before reading this guide. +This guide covers advanced concepts about widgets. Generally, it begins with simpler concepts and increases in complexity. For most beginning users, these details won't be important to know right away. When you want to dynamically change widgets or preserve widget information between pages, these concepts will be important to understand. We recommend having a basic understanding of [Session State](/develop/api-reference/caching-and-state/st.session_state) before reading this guide. diff --git a/content/library/advanced-features/app-menu.md b/content/library/advanced-features/app-menu.md index fbed9ad0d..4da6d108e 100644 --- a/content/library/advanced-features/app-menu.md +++ b/content/library/advanced-features/app-menu.md @@ -1,6 +1,6 @@ --- title: ⋮ App menu -slug: /library/advanced-features/app-menu +slug: /develop/concepts/architecture/app-chrome --- # more_vert App menu @@ -15,7 +15,7 @@ The menu is split into two sections. The upper section contains options availabl ### Rerun -You can manually trigger a rerun of your app by clicking "**Rerun**" from the app menu. This rerun will not reset your session. Your widget states and values stored in [`st.session_state`](/library/advanced-features/session-state) will be preserved. As a shortcut, without opening the app menu, you can rerun your app by pressing "**R**" on your keyboard (if you aren't currently focused on an input element). +You can manually trigger a rerun of your app by clicking "**Rerun**" from the app menu. This rerun will not reset your session. Your widget states and values stored in [`st.session_state`](/develop/concepts/architecture/session-state) will be preserved. As a shortcut, without opening the app menu, you can rerun your app by pressing "**R**" on your keyboard (if you aren't currently focused on an input element).
    Rerun @@ -23,7 +23,7 @@ You can manually trigger a rerun of your app by clicking "**Rerun**" from the ap ### Settings -With the "**Settings**" option, you can control the appearance of your app while it is running. If viewing the app locally, you can set how your app responds to changes in your source code. See more about development flow in [Main concepts](/get-started/fundamentals/main-concepts#development-flow). You can also force your app to appear in wide mode, even if not set within the script using [`st.set_page_config`](/library/api-reference/utilities/st.set_page_config). +With the "**Settings**" option, you can control the appearance of your app while it is running. If viewing the app locally, you can set how your app responds to changes in your source code. See more about development flow in [Basic concepts](/get-started/fundamentals/main-concepts#development-flow). You can also force your app to appear in wide mode, even if not set within the script using [`st.set_page_config`](/develop/api-reference/configuration/st.set_page_config).
    Settings @@ -103,7 +103,7 @@ The whole process looks like this: ### About -You can conveniently check what version of Streamlit is running from the "**About**" option. Developers also have the option to customize the message shown here using [`st.set_page_config`](/library/api-reference/utilities/st.set_page_config). +You can conveniently check what version of Streamlit is running from the "**About**" option. Developers also have the option to customize the message shown here using [`st.set_page_config`](/develop/api-reference/configuration/st.set_page_config).
    Rerun @@ -115,7 +115,7 @@ By default, developer options only show when viewing an app locally or when view ### Clear cache -Reset your app's cache by clicking "**Clear cache**" from the app's menu or by pressing "**C**" on your keyboard while not focused on an input element. This will remove all cached entries for [`@st.cache_data`](/library/api-reference/performance/st.cache_data) and [`@st.cache_resource`](/library/api-reference/performance/st.cache_resource). +Reset your app's cache by clicking "**Clear cache**" from the app's menu or by pressing "**C**" on your keyboard while not focused on an input element. This will remove all cached entries for [`@st.cache_data`](/develop/api-reference/caching-and-state/st.cache_data) and [`@st.cache_resource`](/develop/api-reference/caching-and-state/st.cache_resource).
    Rerun @@ -123,7 +123,7 @@ Reset your app's cache by clicking "**Clear cache**" from the app's menu or by p ### Deploy this app -If you are running an app locally from within a git repo, you can deploy your app to Streamlit Community Cloud in a few easy clicks! Make sure your work has been pushed to your online GitHub repository before beginning. For the greatest convenience, make sure you have already created your [Community Cloud account](/streamlit-community-cloud/get-started/create-your-account) and are signed in. +If you are running an app locally from within a git repo, you can deploy your app to Streamlit Community Cloud in a few easy clicks! Make sure your work has been pushed to your online GitHub repository before beginning. For the greatest convenience, make sure you have already created your [Community Cloud account](/deploy/streamlit-community-cloud/get-started/create-your-account) and are signed in. 1. Click "**Deploy**" next to the app menu icon (more_vert). @@ -137,7 +137,7 @@ If you are running an app locally from within a git repo, you can deploy your ap Settings
    -3. You will be taken to Community Cloud's "Deploy an app" page. Your app's repository, branch, and file name will be prefilled to match your current app! Learn more about [deploying an app](/streamlit-community-cloud/deploy-your-app) on Streamlit Community Cloud. +3. You will be taken to Community Cloud's "Deploy an app" page. Your app's repository, branch, and file name will be prefilled to match your current app! Learn more about [deploying an app](/deploy/streamlit-community-cloud/deploy-your-app) on Streamlit Community Cloud. The whole process looks like this: @@ -147,9 +147,9 @@ The whole process looks like this: ## Customize the menu -Using `client.toolbarMode` in your app's [configuration](/library/advanced-features/configuration), you can make the app menu appear in the following ways: +Using `client.toolbarMode` in your app's [configuration](/develop/concepts/configuration), you can make the app menu appear in the following ways: - `"developer"` — Show the developer options to all viewers. - `"viewer"` — Hide the developer options from all viewers. -- `"minimal"` — Show only those options set externally. These options can be declared through [`st.set_page_config`](/library/api-reference/utilities/st.set_page_config) or populated through Streamlit Community Cloud. +- `"minimal"` — Show only those options set externally. These options can be declared through [`st.set_page_config`](/develop/api-reference/configuration/st.set_page_config) or populated through Streamlit Community Cloud. - `"auto"` — This is the default and will show the developer options when accessed through localhost or through Streamlit Community Cloud when logged into an administrative account for the app. Otherwise, the developer options will not show. diff --git a/content/library/advanced-features/app-testing/_app-testing.md b/content/library/advanced-features/app-testing/_index.md similarity index 84% rename from content/library/advanced-features/app-testing/_app-testing.md rename to content/library/advanced-features/app-testing/_index.md index ba0eef9a2..78dee0214 100644 --- a/content/library/advanced-features/app-testing/_app-testing.md +++ b/content/library/advanced-features/app-testing/_index.md @@ -1,6 +1,6 @@ --- title: Streamlit's native app testing framework -slug: /library/advanced-features/app-testing +slug: /develop/concepts/app-testing --- # Streamlit's native app testing framework @@ -14,30 +14,30 @@ The provided class, AppTest, simulates a running app and provides methods to set color="indigo-70" icon="science" bold="Get started" - href="/library/advanced-features/app-testing/get-started" + href="/develop/concepts/app-testing/get-started" >introduces you to the app testing framework and how to execute tests using pytest. Learn how to initialize and run simulated apps, including how to retrieve, manipulate, and inspect app elements. explains how to work with secrets and Session State within app tests, including how to test multipage apps. with Continuous Integration (CI) to validate app changes over time. puts together the concepts explained above. Check out an app with multiple tests in place. is a compact reference summarizing the available syntax. diff --git a/content/library/advanced-features/app-testing/automate-tests.md b/content/library/advanced-features/app-testing/automate-tests.md index 5ccafc5fd..cfa4446af 100644 --- a/content/library/advanced-features/app-testing/automate-tests.md +++ b/content/library/advanced-features/app-testing/automate-tests.md @@ -1,6 +1,6 @@ --- title: Automate your tests with CI -slug: /library/advanced-features/app-testing/automate-tests +slug: /develop/concepts/app-testing/automate-tests --- # Automate your tests with CI diff --git a/content/library/advanced-features/app-testing/beyond-the-basics.md b/content/library/advanced-features/app-testing/beyond-the-basics.md index e83ca963c..0ca714da7 100644 --- a/content/library/advanced-features/app-testing/beyond-the-basics.md +++ b/content/library/advanced-features/app-testing/beyond-the-basics.md @@ -1,11 +1,11 @@ --- title: Beyond the basics of app testing -slug: /library/advanced-features/app-testing/beyond-the-basics +slug: /develop/concepts/app-testing/beyond-the-basics --- # Beyond the basics of app testing -Now that you're comfortable with executing a basic test for a Streamlit app let's cover the mutable attributes of [`AppTest`](/library/api-reference/app-testing/st.testing.v1.apptest): +Now that you're comfortable with executing a basic test for a Streamlit app let's cover the mutable attributes of [`AppTest`](/develop/api-reference/app-testing/st.testing.v1.apptest): - `AppTest.secrets` - `AppTest.session_state` diff --git a/content/library/advanced-features/app-testing/cheat-sheet.md b/content/library/advanced-features/app-testing/cheat-sheet.md index 2445f7f3f..476dad7dd 100644 --- a/content/library/advanced-features/app-testing/cheat-sheet.md +++ b/content/library/advanced-features/app-testing/cheat-sheet.md @@ -1,6 +1,6 @@ --- title: App testing cheat sheet -slug: /library/advanced-features/app-testing/cheat-sheet +slug: /develop/concepts/app-testing/cheat-sheet --- # App testing cheat sheet diff --git a/content/library/advanced-features/app-testing/examples.md b/content/library/advanced-features/app-testing/examples.md index 796c409f6..ff39f47da 100644 --- a/content/library/advanced-features/app-testing/examples.md +++ b/content/library/advanced-features/app-testing/examples.md @@ -1,6 +1,6 @@ --- title: App testing example -slug: /library/advanced-features/app-testing/examples +slug: /develop/concepts/app-testing/examples --- # App testing example diff --git a/content/library/advanced-features/app-testing/get-started.md b/content/library/advanced-features/app-testing/get-started.md index 1f168f8bb..8855de0a1 100644 --- a/content/library/advanced-features/app-testing/get-started.md +++ b/content/library/advanced-features/app-testing/get-started.md @@ -1,6 +1,6 @@ --- title: Get started with app testing -slug: /library/advanced-features/app-testing/get-started +slug: /develop/concepts/app-testing/get-started --- # Get started with app testing @@ -149,11 +149,11 @@ pytest tests/ Now that you understand the basics of `pytest` let's dive into using Streamlit's app testing framework. Every test begins with initializing and running your simulated app. Additional commands are used to retrieve, manipulate, and inspect elements. -On the next page, we'll go [Beyond the basics](/library/advanced-features/app-testing/beyond-the-basics) and cover more advanced scenarios like working with secrets, Session State, or multipage apps. +On the next page, we'll go [Beyond the basics](/develop/concepts/app-testing/beyond-the-basics) and cover more advanced scenarios like working with secrets, Session State, or multipage apps. ### How to initialize and run a simulated app -To test a Streamlit app, you must first initialize an instance of [`AppTest`](/library/api-reference/app-testing/st.testing.v1.apptest) with the code for one page of your app. There are three methods for initializing a simulated app. These are provided as class methods to `AppTest`. We will focus on `AppTest.from_file()` which allows you to provide a path to a page of your app. This is the most common scenario for building automated tests during app development. `AppTest.from_string()` and `AppTest.from_function()` may be helpful for some simple or experimental scenarios. +To test a Streamlit app, you must first initialize an instance of [`AppTest`](/develop/api-reference/app-testing/st.testing.v1.apptest) with the code for one page of your app. There are three methods for initializing a simulated app. These are provided as class methods to `AppTest`. We will focus on `AppTest.from_file()` which allows you to provide a path to a page of your app. This is the most common scenario for building automated tests during app development. `AppTest.from_string()` and `AppTest.from_function()` may be helpful for some simple or experimental scenarios. Let's continue with the [example from above](#example-project-with-app-testing). @@ -196,7 +196,7 @@ The attributes of the `AppTest` class return sequences of elements. The elements Each attribute of `AppTest` returns a sequence of the associated element type. Specific elements can be retrieved by index. In the above example, `at.number_input` returns a sequence of all `st.number_input` elements in the app. Thus, `at.number_input[0]` is the first such element in the app. Similarly, `at.markdown` returns a collection of all `st.markdown` elements where `at.markdown[0]` is the first such element. -Check out the current list of supported elements in the "Attributes" section of the [`AppTest`](/library/api-reference/app-testing/st.testing.v1.apptest) class or the [App testing cheat sheet](/library/advanced-features/app-testing/cheat-sheet). You can also use the `.get()` method and pass the attribute's name. `at.get("number_input")` and `at.get("markdown")` are equivalent to `at.number_input` and `at.markdown`, respectively. +Check out the current list of supported elements in the "Attributes" section of the [`AppTest`](/develop/api-reference/app-testing/st.testing.v1.apptest) class or the [App testing cheat sheet](/develop/concepts/app-testing/cheat-sheet). You can also use the `.get()` method and pass the attribute's name. `at.get("number_input")` and `at.get("markdown")` are equivalent to `at.number_input` and `at.markdown`, respectively. The returned sequence of elements is ordered by appearance on the page. If containers are used to insert elements in a different order, these sequences may not match the order within your code. Consider the following example where containers are used to switch the order of two buttons on the page: @@ -241,7 +241,7 @@ For `AppTest.columns` and `AppTest.tabs`, a sequence of containers is returned. ### How to manipulate widgets -All widgets have a universal `.set_value()` method. Additionally, many widgets have specific methods for manipulating their value. The names of [Testing element classes](/library/api-reference/app-testing/testing-element-classes) closely match the names of the `AppTest` attributes. For example, look at the return type of [`AppTest.button`](/library/api-reference/app-testing/st.testing.v1.apptest#apptestbutton) to see the corresponding class of [`Button`](/library/api-reference/app-testing/testing-element-classes#sttestingv1element_treebutton). Aside from setting the value of a button with `.set_value()`, you can also use `.click()`. Check out each testing element class for its specific methods. +All widgets have a universal `.set_value()` method. Additionally, many widgets have specific methods for manipulating their value. The names of [Testing element classes](/develop/api-reference/app-testing/testing-element-classes) closely match the names of the `AppTest` attributes. For example, look at the return type of [`AppTest.button`](/develop/api-reference/app-testing/st.testing.v1.apptest#apptestbutton) to see the corresponding class of [`Button`](/develop/api-reference/app-testing/testing-element-classes#sttestingv1element_treebutton). Aside from setting the value of a button with `.set_value()`, you can also use `.click()`. Check out each testing element class for its specific methods. ### How to inspect elements @@ -267,6 +267,6 @@ assert at.selectbox[0].disabled == False -Note that the `options` for `st.selectbox` were declared as integers but asserted as strings. As noted in the documentation for [`st.selectbox`](/library/api-reference/widgets/st.selectbox), options are cast internally to strings. If you ever find yourself getting unexpected results, check the documentation carefully for any notes about recasting types internally. +Note that the `options` for `st.selectbox` were declared as integers but asserted as strings. As noted in the documentation for [`st.selectbox`](/develop/api-reference/widgets/st.selectbox), options are cast internally to strings. If you ever find yourself getting unexpected results, check the documentation carefully for any notes about recasting types internally. diff --git a/content/library/advanced-features/button-behavior-and-examples.md b/content/library/advanced-features/button-behavior-and-examples.md index ffc184b73..dfe79e7bd 100644 --- a/content/library/advanced-features/button-behavior-and-examples.md +++ b/content/library/advanced-features/button-behavior-and-examples.md @@ -1,15 +1,15 @@ --- title: Button behavior and examples -slug: /library/advanced-features/button-behavior-and-examples +slug: /develop/concepts/design/buttons --- # Button behavior and examples ## Summary -Buttons created with [`st.button`](/library/api-reference/widgets/st.button) do not retain state. They return `True` on the script rerun resulting from their click and immediately return to `False` on the next script rerun. If a displayed element is nested inside `if st.button('Click me'):`, the element will be visible when the button is clicked and disappear as soon as the user takes their next action. This is because the script reruns and the button return value becomes `False`. +Buttons created with [`st.button`](/develop/api-reference/widgets/st.button) do not retain state. They return `True` on the script rerun resulting from their click and immediately return to `False` on the next script rerun. If a displayed element is nested inside `if st.button('Click me'):`, the element will be visible when the button is clicked and disappear as soon as the user takes their next action. This is because the script reruns and the button return value becomes `False`. -In this guide, we will illustrate the use of buttons and explain common misconceptions. Read on to see a variety of examples that expand on `st.button` using [`st.session_state`](/library/api-reference/session-state). [Anti-patterns](#anti-patterns) are included at the end. Go ahead and pull up your favorite code editor so you can `streamlit run` the examples as you read. Check out Streamlit's [Main concepts](/get-started/fundamentals/main-concepts) if you haven't run your own Streamlit scripts yet. +In this guide, we will illustrate the use of buttons and explain common misconceptions. Read on to see a variety of examples that expand on `st.button` using [`st.session_state`](/develop/api-reference/caching-and-state/st.session_state). [Anti-patterns](#anti-patterns) are included at the end. Go ahead and pull up your favorite code editor so you can `streamlit run` the examples as you read. Check out Streamlit's [Basic concepts](/get-started/fundamentals/main-concepts) if you haven't run your own Streamlit scripts yet. ## When to use `if st.button()` @@ -38,7 +38,7 @@ need to keep that info. If you want to give the user a quick button to check if an entry is valid, but not keep that check displayed as the user continues. -In this example, a user can click a button to check if their `animal` string is in the `animal_shelter` list. When the user clicks "**Check availability**" they will see "We have that animal!" or "We don't have that animal." If they change the animal in [`st.text_input`](/library/api-reference/widgets/st.text_input), the script reruns and the message disappears until they click "**Check availability**" again. +In this example, a user can click a button to check if their `animal` string is in the `animal_shelter` list. When the user clicks "**Check availability**" they will see "We have that animal!" or "We don't have that animal." If they change the animal in [`st.text_input`](/develop/api-reference/widgets/st.text_input), the script reruns and the message disappears until they click "**Check availability**" again. ```python import streamlit as st @@ -52,7 +52,7 @@ if st.button('Check availability'): 'We have that animal!' if have_it else 'We don\'t have that animal.' ``` -Note: The above example uses [magic](/library/api-reference/write-magic/magic) to render the message on the frontend. +Note: The above example uses [magic](/develop/api-reference/write-magic/magic) to render the message on the frontend. ### Stateful button @@ -77,9 +77,9 @@ if st.session_state.clicked: ### Toggle button -If you want a button to work like a toggle switch, consider using [`st.checkbox`](/library/api-reference/widgets/st.checkbox). Otherwise, you can use a button with a callback function to reverse a boolean value saved in `st.session_state`. +If you want a button to work like a toggle switch, consider using [`st.checkbox`](/develop/api-reference/widgets/st.checkbox). Otherwise, you can use a button with a callback function to reverse a boolean value saved in `st.session_state`. -In this example, we use `st.button` to toggle another widget on and off. By displaying [`st.slider`](/library/api-reference/widgets/st.slider) conditionally on a value in `st.session_state`, the user can interact with the slider without it disappearing. +In this example, we use `st.button` to toggle another widget on and off. By displaying [`st.slider`](/develop/api-reference/widgets/st.slider) conditionally on a value in `st.session_state`, the user can interact with the slider without it disappearing. ```python import streamlit as st @@ -207,7 +207,7 @@ st.header(st.session_state['name']) #### Logic nested in a button with a rerun -Although callbacks are often preferred to avoid extra reruns, our first 'John Doe'/'Jane Doe' example can be modified by adding [`st.rerun`](/library/api-reference/control-flow/st.rerun) instead. If you need to acces data in `st.session_state` before the button that modifies it, you can include `st.rerun` to rerun the script after the change has been committed. This means the script will rerun twice when a button is clicked. +Although callbacks are often preferred to avoid extra reruns, our first 'John Doe'/'Jane Doe' example can be modified by adding [`st.rerun`](/develop/api-reference/execution-flow/st.rerun) instead. If you need to acces data in `st.session_state` before the button that modifies it, you can include `st.rerun` to rerun the script after the change has been committed. This means the script will rerun twice when a button is clicked. ```python import streamlit as st @@ -288,7 +288,7 @@ st.button('Streamlit!', on_click=set_name, args=['Streamlit']) #### Option 3: Use containers -By using [`st.container`](/library/api-reference/layout/st.container) you can have widgets appear in different orders in your script and frontend view (webpage). +By using [`st.container`](/develop/api-reference/layout/st.container) you can have widgets appear in different orders in your script and frontend view (webpage). ```python import streamlit as st @@ -371,7 +371,7 @@ if option in st.session_state.processed: st.write(st.session_state.processed[option][0]) ``` -Astute observers may think, "This feels a little like caching." We are only saving results relative to one parameter, but the pattern could easily be expanded to save results relative to both parameters. In that sense, yes, it has some similarities to caching, but also some important differences. When you save results in `st.session_state`, the results are only available to the current user in their current session. If you use [`st.cache_data`](/library/api-reference/performance/st.cache_data) instead, the results are available to all users across all sessions. Furthermore, if you want to update a saved result, you have to clear all saved results for that function to do so. +Astute observers may think, "This feels a little like caching." We are only saving results relative to one parameter, but the pattern could easily be expanded to save results relative to both parameters. In that sense, yes, it has some similarities to caching, but also some important differences. When you save results in `st.session_state`, the results are only available to the current user in their current session. If you use [`st.cache_data`](/develop/api-reference/caching-and-state/st.cache_data) instead, the results are available to all users across all sessions. Furthermore, if you want to update a saved result, you have to clear all saved results for that function to do so. ## Anti-patterns diff --git a/content/library/advanced-features/caching.md b/content/library/advanced-features/caching.md index bd1513880..17e1a83be 100644 --- a/content/library/advanced-features/caching.md +++ b/content/library/advanced-features/caching.md @@ -1,15 +1,15 @@ --- -title: Caching -slug: /library/advanced-features/caching +title: Caching overview +slug: /develop/concepts/architecture/caching --- -Documentation for the deprecated `@st.cache` decorator can be found in [Optimize performance with st.cache](/library/advanced-features/st.cache). +Documentation for the deprecated `@st.cache` decorator can be found in [Optimize performance with st.cache](/develop/concepts/architecture/st.cache). -# Caching +# Caching overview Streamlit runs your script from top to bottom at every user interaction or code change. This execution model makes development super easy. But it comes with two major challenges: @@ -99,7 +99,7 @@ Run the app again. You'll notice that the slow download only happens on the firs How does this work? Let's go through the behavior of `st.cache_data` step by step: - On the first run, Streamlit recognizes that it has never called the `load_data` function with the specified parameter value (the URL of the CSV file) So it runs the function and downloads the data. -- Now our caching mechanism becomes active: the returned DataFrame is serialized (converted to bytes) via [pickle](https://docs.python.org/3/library/pickle.html) and stored in the cache (together with the value of the `url` parameter). +- Now our caching mechanism becomes active: the returned DataFrame is serialized (converted to bytes) via [pickle](https://docs.python.org/3/develop/pickle.html) and stored in the cache (together with the value of the `url` parameter). - On the next run, Streamlit checks the cache for an entry of `load_data` with the specific `url`. There is one! So it retrieves the cached object, deserializes it to a DataFrame, and returns it instead of re-running the function and downloading the data again. This process of serializing and deserializing the cached object creates a copy of our original DataFrame. While this copying behavior may seem unnecessary, it's what we want when caching data objects since it effectively prevents mutation and concurrency issues. Read the section “[Mutation and concurrency issues](#mutation-and-concurrency-issues)" below to understand this in more detail. @@ -138,7 +138,7 @@ def add(arr1, arr2): **Database queries** -You usually make SQL queries to load data into your app when working with databases. Repeatedly running these queries can be slow, cost money, and degrade the performance of your database. We strongly recommend caching any database queries in your app. See also [our guides on connecting Streamlit to different databases](/knowledge-base/tutorials/databases) for in-depth examples. +You usually make SQL queries to load data into your app when working with databases. Repeatedly running these queries can be slow, cost money, and degrade the performance of your database. We strongly recommend caching any database queries in your app. See also [our guides on connecting Streamlit to different databases](/develop/tutorials/databases) for in-depth examples. ```python connection = database.connect() @@ -248,7 +248,7 @@ def init_connection(): conn = init_connection() ``` -Of course, you can do the same for any other database. Have a look at [our guides on how to connect Streamlit to databases](/knowledge-base/tutorials/databases) for in-depth examples. +Of course, you can do the same for any other database. Have a look at [our guides on how to connect Streamlit to databases](/develop/tutorials/databases) for in-depth examples. **Loading ML models** @@ -270,7 +270,7 @@ model = load_model() The sections above showed many common examples for each caching decorator. But there are edge cases for which it's less trivial to decide which caching decorator to use. Eventually, it all comes down to the difference between “data" and “resource": -- Data are serializable objects (objects that can be converted to bytes via [pickle](https://docs.python.org/3/library/pickle.html)) that you could easily save to disk. Imagine all the types you would usually store in a database or on a file system – basic types like str, int, and float, but also arrays, DataFrames, images, or combinations of these types (lists, tuples, dicts, and so on). +- Data are serializable objects (objects that can be converted to bytes via [pickle](https://docs.python.org/3/develop/pickle.html)) that you could easily save to disk. Imagine all the types you would usually store in a database or on a file system – basic types like str, int, and float, but also arrays, DataFrames, images, or combinations of these types (lists, tuples, dicts, and so on). - Resources are unserializable objects that you usually would not save to disk or a database. They are often more complex, non-permanent objects like database connections, ML models, file handles, threads, etc. From the types listed above, it should be obvious that most objects in Python are “data." That's also why `st.cache_data` is the correct command for almost all use cases. `st.cache_resource` is a more exotic command that you should only use in specific situations. @@ -733,7 +733,7 @@ def show_data(): #### Input widgets -You can also use [interactive input widgets](/library/api-reference/widgets) like `st.slider` or `st.text_input` in cached functions. Widget replay is an experimental feature at the moment. To enable it, you need to set the `experimental_allow_widgets` parameter: +You can also use [interactive input widgets](/develop/api-reference/widgets) like `st.slider` or `st.text_input` in cached functions. Widget replay is an experimental feature at the moment. To enable it, you need to set the `experimental_allow_widgets` parameter: ```python @st.cache_data(experimental_allow_widgets=True) # 👈 Set the parameter diff --git a/content/library/advanced-features/configuration.md b/content/library/advanced-features/configuration.md index 9f0afd824..138f61c8b 100644 --- a/content/library/advanced-features/configuration.md +++ b/content/library/advanced-features/configuration.md @@ -1,15 +1,15 @@ --- -title: Configuration -slug: /library/advanced-features/configuration +title: Working with configuration options +slug: /develop/concepts/configuration/options --- -# Configuration +# Working with configuration options Streamlit provides four different ways to set configuration options. This list is in reverse order of precedence, i.e. command line flags take precedence over environment variables when the same configuration option is provided multiple times. -If changes to `.streamlit/config.toml` are made _while_ the app is running, the server needs to be restarted for changes to be reflected in the app. +If you change theme settings in `.streamlit/config.toml` _while_ the app is running, these changes will reflect immediately. If you change non-theme settings in `.streamlit/config.toml` _while_ the app is running, the server needs to be restarted for changes to be reflected in the app. @@ -53,362 +53,13 @@ gatherUsageStats = false ## Theming You can change the base colors of your app using the `[theme]` section of the configuration system. -To learn more, see [Theming.](/library/advanced-features/theming) +To learn more, see [Theming.](/develop/concepts/configuration/theming) ## View all configuration options -As described in [Command-line options](/library/advanced-features/cli), you can +As described in [Command-line options](/develop/api-reference/cli), you can view all available configuration option using: ```bash streamlit config show ``` - -Below are all the sections and options you can have in your `.streamlit/config.toml` file: - -### Global - -```toml -[global] - -# ***DEPRECATED*** -# global.disableWatchdogWarning has been deprecated has been deprecated and -# will be removed in a future version. This option will be removed on or after -# 2024-01-20. -# **************** -# By default, Streamlit checks if the Python watchdog module is available -# and, if not, prints a warning asking for you to install it. The watchdog -# module is not required, but highly recommended. It improves Streamlit's -# ability to detect changes to files in your filesystem. -# If you'd like to turn off this warning, set this to True. -# Default: false -disableWatchdogWarning = false - -# By default, Streamlit displays a warning when a user sets both a widget -# default value in the function defining the widget and a widget value via -# the widget's key in `st.session_state`. -# If you'd like to turn off this warning, set this to True. -# Default: false -disableWidgetStateDuplicationWarning = false - -# If True, will show a warning when you run a Streamlit-enabled script -# via "python my_script.py". -# Default: true -showWarningOnDirectExecution = true -``` - -### Logger - -```toml -[logger] - -# Level of logging: 'error', 'warning', 'info', or 'debug'. -# Default: 'info' -level = "info" - -# String format for logging messages. If logger.datetimeFormat is set, -# logger messages will default to `%(asctime)s.%(msecs)03d %(message)s`. See -# Python's documentation for available attributes: -# https://docs.python.org/2.6/library/logging.html#formatter-objects -# Default: "%(asctime)s %(message)s" -messageFormat = "%(asctime)s %(message)s" -``` - -### Client - -```toml -[client] - -# ***DEPRECATED*** -# client.caching has been deprecated and is not required anymore for our new -# caching commands. This option will be removed on or after 2024-01-20. -# **************** -# Whether to enable st.cache. This does not affect st.cache_data or -# st.cache_resource. -# Default: true -caching = true - -# ***DEPRECATED*** -# client.displayEnabled has been deprecated and will be removed in a future -# version. This option will be removed on or after 2024-01-20. -# **************** -# If false, makes your Streamlit script not draw to a Streamlit app. -# Default: true -displayEnabled = true - -# Controls whether uncaught app exceptions and deprecation warnings -# are displayed in the browser. By default, this is set to True and -# Streamlit displays app exceptions and associated tracebacks, and -# deprecation warnings, in the browser. -# -# If set to False, deprecation warnings and full exception messages -# will print to the console only. Exceptions will still display in the -# browser with a generic error message. For now, the exception type and -# traceback show in the browser also, but they will be removed in the -# future. -# Default: true -showErrorDetails = true - -# Change the visibility of items in the toolbar, options menu, -# and settings dialog (top right of the app). -# Allowed values: -# * "auto" : Show the developer options if the app is accessed through -# localhost or through Streamlit Community Cloud as a developer. -# Hide them otherwise. -# * "developer" : Show the developer options. -# * "viewer" : Hide the developer options. -# * "minimal" : Show only options set externally (e.g. through -# Streamlit Community Cloud) or through st.set_page_config. -# If there are no options left, hide the menu. -# Default: "auto" -toolbarMode = "auto" - -# Controls whether the default sidebar page navigation in a multipage app is -# displayed. -# Default: true -showSidebarNavigation = true -``` - -### Runner - -```toml -[runner] - -# Allows you to type a variable or string by itself in a single line of -# Python code to write it to the app. -# Default: true -magicEnabled = true - -# ***DEPRECATED*** -# runner.installTracer has been deprecated and will be removed in a future -# version. This option will be removed on or after 2024-01-20. -# **************** -# Install a Python tracer to allow you to stop or pause your script at -# any point and introspect it. As a side-effect, this slows down your -# script's execution. -# Default: false -installTracer = false - -# ***DEPRECATED*** -# runner.fixMatplotlib has been deprecated and will be removed in a future -# version. This option will be removed on or after 2024-01-20. -# **************** -# Sets the MPLBACKEND environment variable to Agg inside Streamlit to -# prevent Python crashing. -# Default: true -fixMatplotlib = true - -# Handle script rerun requests immediately, rather than waiting for script -# execution to reach a yield point. This makes Streamlit much more -# responsive to user interaction, but it can lead to race conditions in -# apps that mutate session_state data outside of explicit session_state -# assignment statements. -# Default: true -fastReruns = true - -# Raise an exception after adding unserializable data to Session State. -# 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. -# Default: false -enforceSerializableSessionState = false - -# Adjust how certain 'options' widgets like radio, selectbox, and -# multiselect coerce Enum members when the Enum class gets -# re-defined during a script re-run. For more information, check out the docs: -# https://docs.streamlit.io/library/advanced-features/custom-classes#enums -# -# Allowed values: -# * "off" : Disables Enum coercion. -# * "nameOnly" : Enum classes can be coerced if their member names match. -# * "nameAndValue" : Enum classes can be coerced if their member names AND -# member values match. -# Default: "nameOnly" -enumCoercion = "nameOnly" -``` - -### Server - -```toml -[server] - -# List of folders that should not be watched for changes. This -# impacts both "Run on Save" and @st.cache. -# Relative paths will be taken as relative to the current working directory. -# Example: ['/home/user1/env', 'relative/path/to/folder'] -# Default: [] -folderWatchBlacklist = [] - -# Change the type of file watcher used by Streamlit, or turn it off -# completely. -# Allowed values: -# * "auto" : Streamlit will attempt to use the watchdog module, and -# falls back to polling if watchdog is not available. -# * "watchdog" : Force Streamlit to use the watchdog module. -# * "poll" : Force Streamlit to always use polling. -# * "none" : Streamlit will not watch files. -# Default: "auto" -fileWatcherType = "auto" - -# Symmetric key used to produce signed cookies. If deploying on multiple -# replicas, this should be set to the same value across all replicas to ensure -# they all share the same secret. -# Default: randomly generated secret key. -cookieSecret = "a-random-key-appears-here" - -# If false, will attempt to open a browser window on start. -# Default: false unless (1) we are on a Linux box where DISPLAY is unset, or -# (2) we are running in the Streamlit Atom plugin. -headless = false - -# Automatically rerun script when the file is modified on disk. -# Default: false -runOnSave = false - -# The address where the server will listen for client and browser -# connections. Use this if you want to bind the server to a specific address. -# If set, the server will only be accessible from this address, and not from -# any aliases (like localhost). -# Default: (unset) -address = - -# The port where the server will listen for browser connections. -# Don't use port 3000 which is reserved for internal development. -# Default: 8501 -port = 8501 - -# The base path for the URL where Streamlit should be served from. -# Default: "" -baseUrlPath = "" - -# Enables support for Cross-Origin Resource Sharing (CORS) protection, for -# added security. -# Due to conflicts between CORS and XSRF, if `server.enableXsrfProtection` is -# on and `server.enableCORS` is off at the same time, we will prioritize -# `server.enableXsrfProtection`. -# Default: true -enableCORS = true - -# Enables support for Cross-Site Request Forgery (XSRF) protection, for added -# security. -# Due to conflicts between CORS and XSRF, if `server.enableXsrfProtection` is -# on and `server.enableCORS` is off at the same time, we will prioritize -# `server.enableXsrfProtection`. -# Default: true -enableXsrfProtection = true - -# Max size, in megabytes, for files uploaded with the file_uploader. -# Default: 200 -maxUploadSize = 200 - -# Max size, in megabytes, of messages that can be sent via the WebSocket -# connection. -# Default: 200 -maxMessageSize = 200 - -# Enables support for websocket compression. -# Default: false -enableWebsocketCompression = false - -# Enable serving files from a `static` directory in the running app's -# directory. -# Default: false -enableStaticServing = false - -# Server certificate file for connecting via HTTPS. -# Must be set at the same time as "server.sslKeyFile". -# ['DO NOT USE THIS OPTION IN A PRODUCTION ENVIRONMENT. It has not gone through -# security audits or performance tests. For the production environment, we -# recommend performing SSL termination by the load balancer or the reverse -# proxy.'] -# sslCertFile = - -# Cryptographic key file for connecting via HTTPS. -# Must be set at the same time as "server.sslCertFile". -# ['DO NOT USE THIS OPTION IN A PRODUCTION ENVIRONMENT. It has not gone through -# security audits or performance tests. For the production environment, we -# recommend performing SSL termination by the load balancer or the reverse -# proxy.'] -# sslKeyFile = -``` - -### Browser - -```toml -[browser] - -# Internet address where users should point their browsers in order to -# connect to the app. Can be IP address or DNS name and path. -# This is used to: -# - Set the correct URL for CORS and XSRF protection purposes. -# - Show the URL on the terminal -# - Open the browser -# Default: "localhost" -serverAddress = "localhost" - -# Whether to send usage statistics to Streamlit. -# Default: true -gatherUsageStats = true - -# Port where users should point their browsers in order to connect to the -# app. -# This is used to: -# - Set the correct URL for XSRF protection purposes. -# - Show the URL on the terminal (part of `streamlit run`). -# - Open the browser automatically (part of `streamlit run`). -# This option is for advanced use cases. To change the port of your app, use -# `server.Port` instead. Don't use port 3000 which is reserved for internal -# development. -# Default: whatever value is set in server.port. -serverPort = 8501 -``` - -### Mapbox - -```toml -[mapbox] - -# Configure Streamlit to use a custom Mapbox -# token for elements like st.pydeck_chart and st.map. -# To get a token for yourself, create an account at -# https://mapbox.com. It's free (for moderate usage levels)! -# Default: "" -token = "" -``` - -### Deprecation - -```toml -[deprecation] - -# Set to false to disable the deprecation warning for using the global pyplot -# instance. -# Default: true -showPyplotGlobalUse = true -``` - -### Theme - -```toml -[theme] - -# The preset Streamlit theme that your custom theme inherits from. -# One of "light" or "dark". -# base = - -# Primary accent color for interactive elements. -# primaryColor = - -# Background color for the main content area. -# backgroundColor = - -# Background color used for the sidebar and most interactive widgets. -# secondaryBackgroundColor = - -# Color used for almost all text. -# textColor = - -# Font family for all text in the app, except code blocks. One of "sans serif", -# "serif", or "monospace". -# font = -``` diff --git a/content/library/advanced-features/configuration/_index.md b/content/library/advanced-features/configuration/_index.md new file mode 100644 index 000000000..896d65a1c --- /dev/null +++ b/content/library/advanced-features/configuration/_index.md @@ -0,0 +1,42 @@ +--- +title: Configure and customize your app +slug: /develop/concepts/configuration +--- + +# Configure and customize your app + + + + + +
    Configuration options
    + +Understand they types of options available to you through Streamlit configuration. + +
    + + + +
    HTTPS support
    + +Understand how to configure SSL and TLS for your Streamlit app. + +
    + + + +
    Static file serving
    + +Understand how to host files alongside your app to make them accessible by URL. Use this if you want to point to files with raw HTML. + +
    + + + +
    Theming
    + +Understand how to use the theming configuration options to customize the color and appearance of your app. + +
    + +
    diff --git a/content/library/advanced-features/connecting-to-data.md b/content/library/advanced-features/connecting-to-data.md index 74a43edea..ce578affc 100644 --- a/content/library/advanced-features/connecting-to-data.md +++ b/content/library/advanced-features/connecting-to-data.md @@ -1,18 +1,18 @@ --- title: Connecting to data -slug: /library/advanced-features/connecting-to-data +slug: /develop/concepts/connections/connecting-to-data --- # Connecting to data Most Streamlit apps need some kind of data or API access to be useful - either retrieving data to view or saving the results of some user action. This data or API is often part of some remote service, database, or other data source. -**Anything you can do with Python, including data connections, will generally work in Streamlit**. Streamlit's [tutorials](/knowledge-base/tutorials/databases) are a great starting place for many data sources. However: +**Anything you can do with Python, including data connections, will generally work in Streamlit**. Streamlit's [tutorials](/develop/tutorials/databases) are a great starting place for many data sources. However: - Connecting to data in a Python application is often tedious and annoying. - There are specific considerations for connecting to data from streamlit apps, such as caching and secrets management. -**Streamlit provides [`st.connection()`](/library/api-reference/connections/st.connection) to more easily connect your Streamlit apps to data and APIs with just a few lines of code**. This page provides a basic example of using the feature and then focuses on advanced usage. +**Streamlit provides [`st.connection()`](/develop/api-reference/connections/st.connection) to more easily connect your Streamlit apps to data and APIs with just a few lines of code**. This page provides a basic example of using the feature and then focuses on advanced usage. For a comprehensive overview of this feature, check out this video tutorial by Joshua Carroll, Streamlit's Product Manager for Developer Experience. You'll learn about the feature's utility in creating and managing data connections within your apps by using real-world examples. @@ -20,7 +20,7 @@ For a comprehensive overview of this feature, check out this video tutorial by J ## Basic usage -For basic startup and usage examples, read up on the relevant [data source tutorial](/knowledge-base/tutorials/databases). Streamlit has built-in connections to SQL dialects and Snowflake. We also maintain installable connections for [Cloud File Storage](https://github.com/streamlit/files-connection) and [Google Sheets](https://github.com/streamlit/gsheets-connection). +For basic startup and usage examples, read up on the relevant [data source tutorial](/develop/tutorials/databases). Streamlit has built-in connections to SQL dialects and Snowflake. We also maintain installable connections for [Cloud File Storage](https://github.com/streamlit/files-connection) and [Google Sheets](https://github.com/streamlit/gsheets-connection). If you are just starting, the best way to learn is to pick a data source you can access and get a minimal example working from one of the pages above 👆. Here, we will provide an ultra-minimal usage example for using a SQLite database. From there, the rest of this page will focus on advanced usage. @@ -40,7 +40,7 @@ To see the example below running live, check out the interactive demo below: #### Step 1: Install prerequisite library - SQLAlchemy -All SQLConnections in Streamlit use SQLAlchemy. For most other SQL dialects, you also need to install the driver. But the [SQLite driver ships with python3](https://docs.python.org/3/library/sqlite3.html), so it isn't necessary. +All SQLConnections in Streamlit use SQLAlchemy. For most other SQL dialects, you also need to install the driver. But the [SQLite driver ships with python3](https://docs.python.org/3/develop/sqlite3.html), so it isn't necessary. ```bash pip install SQLAlchemy==1.4.0 @@ -86,7 +86,7 @@ pet_owners = conn.query('select * from pet_owners') st.dataframe(pet_owners) ``` -In this example, we didn't set a `ttl=` value on the call to [`conn.query()`](/library/api-reference/connections/st.connections.sqlconnection#sqlconnectionquery), meaning Streamlit caches the result indefinitely as long as the app server runs. +In this example, we didn't set a `ttl=` value on the call to [`conn.query()`](/develop/api-reference/connections/st.connections.sqlconnection#sqlconnectionquery), meaning Streamlit caches the result indefinitely as long as the app server runs. Now, on to more advanced topics! 🚀 @@ -94,7 +94,7 @@ Now, on to more advanced topics! 🚀 ### Global secrets, managing multiple apps and multiple data stores -Streamlit [supports a global secrets file](/library/advanced-features/secrets-management) specified in the user's home directory, such as `~/.streamlit/secrets.toml`. If you build or manage multiple apps, we recommend using a global credential or secret file for local development across apps. With this approach, you only need to set up and manage your credentials in one place, and connecting a new app to your existing data sources is effectively a one-liner. It also reduces the risk of accidentally checking in your credentials to git since they don't need to exist in the project repository. +Streamlit [supports a global secrets file](/develop/concepts/connections/secrets-management) specified in the user's home directory, such as `~/.streamlit/secrets.toml`. If you build or manage multiple apps, we recommend using a global credential or secret file for local development across apps. With this approach, you only need to set up and manage your credentials in one place, and connecting a new app to your existing data sources is effectively a one-liner. It also reduces the risk of accidentally checking in your credentials to git since they don't need to exist in the project repository. For cases where you have multiple similar data sources that you connect to during local development (such as a local vs. staging database), you can define different connection sections in your secrets or credentials file for different environments and then decide which to use at runtime. `st.connection` supports this with the _`name=env:`_ syntax. @@ -133,9 +133,9 @@ DB_CONN=staging streamlit run streamlit_app.py ### Advanced SQLConnection configuration -The [SQLConnection](/library/api-reference/connections/st.connections.sqlconnection) configuration uses SQLAlchemy `create_engine()` function. It will take a single URL argument or attempt to construct a URL from several parts (username, database, host, and so on) using [`SQLAlchemy.engine.URL.create()`](https://docs.sqlalchemy.org/en/20/core/engines.html#sqlalchemy.engine.URL.create). +The [SQLConnection](/develop/api-reference/connections/st.connections.sqlconnection) configuration uses SQLAlchemy `create_engine()` function. It will take a single URL argument or attempt to construct a URL from several parts (username, database, host, and so on) using [`SQLAlchemy.engine.URL.create()`](https://docs.sqlalchemy.org/en/20/core/engines.html#sqlalchemy.engine.URL.create). -Several popular SQLAlchemy dialects, such as Snowflake and Google BigQuery, can be configured using additional arguments to `create_engine()` besides the URL. These can be passed as `**kwargs` to the [st.connection](/library/api-reference/connections/st.connection) call directly or specified in an additional secrets section called `create_engine_kwargs`. +Several popular SQLAlchemy dialects, such as Snowflake and Google BigQuery, can be configured using additional arguments to `create_engine()` besides the URL. These can be passed as `**kwargs` to the [st.connection](/develop/api-reference/connections/st.connection) call directly or specified in an additional secrets section called `create_engine_kwargs`. E.g. snowflake-sqlalchemy takes an additional [`connect_args`](https://docs.sqlalchemy.org/en/20/core/engines.html#sqlalchemy.create_engine.params.connect_args) argument as a dictionary for configuration that isn’t supported in the URL. These could be specified as follows: @@ -186,11 +186,11 @@ You can also provide both kwargs and secrets.toml values, and they will be merge ### Connection considerations in frequently used or long-running apps -By default, connection objects are cached without expiration using [`st.cache_resource`](/library/api-reference/performance/st.cache_resource). In most cases this is desired. You can do `st.connection('myconn', type=MyConnection, ttl=)` if you want the connection object to expire after some time. +By default, connection objects are cached without expiration using [`st.cache_resource`](/develop/api-reference/caching-and-state/st.cache_resource). In most cases this is desired. You can do `st.connection('myconn', type=MyConnection, ttl=)` if you want the connection object to expire after some time. Many connection types are expected to be long-running or completely stateless, so expiration is unnecessary. Suppose a connection becomes stale (such as a cached token expiring or a server-side connection being closed). In that case, every connection has a `reset()` method, which will invalidate the cached version and cause Streamlit to recreate the connection the next time it is retrieved -Convenience methods like `query()` and `read()` will typically cache results by default using [`st.cache_data`](/library/api-reference/performance/st.cache_data) without an expiration. When an app can run many different read operations with large results, it can cause high memory usage over time and results to become stale in a long-running app, the same as with any other usage of `st.cache_data`. For production use cases, we recommend setting an appropriate `ttl` on these read operations, such as `conn.read('path/to/file', ttl="1d")`. Refer to [Caching](/library/advanced-features/caching) for more information. +Convenience methods like `query()` and `read()` will typically cache results by default using [`st.cache_data`](/develop/api-reference/caching-and-state/st.cache_data) without an expiration. When an app can run many different read operations with large results, it can cause high memory usage over time and results to become stale in a long-running app, the same as with any other usage of `st.cache_data`. For production use cases, we recommend setting an appropriate `ttl` on these read operations, such as `conn.read('path/to/file', ttl="1d")`. Refer to [Caching](/develop/concepts/architecture/caching) for more information. For apps that could get significant concurrent usage, ensure that you understand any thread safety implications of your connection, particularly when using a connection built by a third party. Connections built by Streamlit should provide thread-safe operations by default. @@ -206,7 +206,7 @@ Check out the [Build your own Connection page](https://experimental-connection.s The typical steps are: -1. Declare the Connection class, extending [`ExperimentalBaseConnection`](/library/api-reference/connections/st.connections.experimentalbaseconnection) with the type parameter bound to the underlying connection object: +1. Declare the Connection class, extending [`ExperimentalBaseConnection`](/develop/api-reference/connections/st.connections.experimentalbaseconnection) with the type parameter bound to the underlying connection object: ```python from streamlit.connections import ExperimentalBaseConnection @@ -234,7 +234,7 @@ We recommend applying the following best practices to make your Connection consi 1. **Extend existing drivers or SDKs, and default to semantics that makes sense for their existing users.** - You should rarely need to implement complex data access logic from scratch when building a Connection. Use existing popular Python drivers and clients whenever possible. Doing so makes your Connection easier to maintain, more secure, and enables users to get the latest features. E.g. [SQLConnection](/library/api-reference/connections/st.connections.sqlconnection) extends SQLAlchemy, [FileConnection](https://github.com/streamlit/files-connection) extends [fsspec](https://filesystem-spec.readthedocs.io/en/latest/), [GsheetsConnection](https://github.com/streamlit/gsheets-connection) extends [gspread](https://docs.gspread.org/en/latest/), etc. + You should rarely need to implement complex data access logic from scratch when building a Connection. Use existing popular Python drivers and clients whenever possible. Doing so makes your Connection easier to maintain, more secure, and enables users to get the latest features. E.g. [SQLConnection](/develop/api-reference/connections/st.connections.sqlconnection) extends SQLAlchemy, [FileConnection](https://github.com/streamlit/files-connection) extends [fsspec](https://filesystem-spec.readthedocs.io/en/latest/), [GsheetsConnection](https://github.com/streamlit/gsheets-connection) extends [gspread](https://docs.gspread.org/en/latest/), etc. Consider using access patterns, method/argument naming, and return values that are consistent with the underlying package and familiar to existing users of that package. @@ -263,4 +263,4 @@ We recommend applying the following best practices to make your Connection consi Connections should provide thread-safe operations when practical (which should be most of the time) and clearly document any considerations around this. Most underlying drivers or SDKs should provide thread-safe objects or methods - use these when possible. - If the underlying driver or SDK has a risk of stateful connection objects becoming stale or invalid, consider building a low impact health check or reset/retry pattern into the access methods. The SQLConnection built into Streamlit has a good example of this pattern using [tenacity](https://tenacity.readthedocs.io/) and the built-in [Connection.reset()](/library/api-reference/connections/st.connections.sqlconnection#sqlconnectionreset) method. An alternate approach is to encourage developers to set an appropriate TTL on the `st.connection()` call to ensure it periodically reinitializes the connection object. + If the underlying driver or SDK has a risk of stateful connection objects becoming stale or invalid, consider building a low impact health check or reset/retry pattern into the access methods. The SQLConnection built into Streamlit has a good example of this pattern using [tenacity](https://tenacity.readthedocs.io/) and the built-in [Connection.reset()](/develop/api-reference/connections/st.connections.sqlconnection#sqlconnectionreset) method. An alternate approach is to encourage developers to set an appropriate TTL on the `st.connection()` call to ensure it periodically reinitializes the connection object. diff --git a/content/library/advanced-features/connections/_index.md b/content/library/advanced-features/connections/_index.md new file mode 100644 index 000000000..29632d66f --- /dev/null +++ b/content/library/advanced-features/connections/_index.md @@ -0,0 +1,34 @@ +--- +title: Working with connections and secrets +slug: /develop/concepts/connections +--- + +# Working with connections and secrets + + + + + +
    Connecting to data
    + +Connect your app to remote data or a third-party API. + +
    + + + +
    Secrets managements
    + +Set up your development environement and design your app to handle secrets securely. + +
    + + + +
    Security reminders
    + +Check out a few reminders to follow best practices and avoid security mistakes. + +
    + +
    diff --git a/content/library/advanced-features/custom-classes.md b/content/library/advanced-features/custom-classes.md index c5bc05c1c..4f7e20d0f 100644 --- a/content/library/advanced-features/custom-classes.md +++ b/content/library/advanced-features/custom-classes.md @@ -1,6 +1,6 @@ --- title: Using custom Python classes in your Streamlit app -slug: /library/advanced-features/custom-classes +slug: /develop/concepts/design/custom-classes --- # Using custom Python classes in your Streamlit app @@ -9,7 +9,7 @@ If you are building a complex Streamlit app or working with existing code, you m - Defining a `@dataclass` to store related data within your app. - Defining an `Enum` class to represent a fixed set of options or values. -- Defining custom interfaces to external services or databases not covered by [`st.connection`](/library/api-reference/connections/st.connection). +- Defining custom interfaces to external services or databases not covered by [`st.connection`](/develop/api-reference/connections/st.connection). Because Streamlit reruns your script after every user interaction, custom classes may be redefined multiple times within the same Streamlit session. This may result in unwanted effects, especially with class and instance comparisons. Read on to understand this common pitfall and how to avoid it. @@ -78,7 +78,7 @@ Streamlit only reloads code in imported modules when it detects the code has cha ### Pattern 2: Force your class to compare internal values -For classes that store data (like [dataclasses](https://docs.python.org/3/library/dataclasses.html)), you may be more interested in comparing the internally stored values rather than the class itself. If you define a custom `__eq__` method, you can force comparisons to be made on the internally stored values. +For classes that store data (like [dataclasses](https://docs.python.org/3/develop/dataclasses.html)), you may be more interested in comparing the internally stored values rather than the class itself. If you define a custom `__eq__` method, you can force comparisons to be made on the internally stored values. #### Example: Define `__eq__` @@ -236,7 +236,7 @@ number = st.selectbox("Pick a number, any number", options=[1, 2, 3]) # number == whatever value the user has selected from the UI. ``` -When you call a function like `st.selectbox` and pass an `Iterable` to `options`, the `Iterable` and current selection are saved into a hidden portion of [Session State](/library/advanced-features/session-state) called the Widget Metadata. +When you call a function like `st.selectbox` and pass an `Iterable` to `options`, the `Iterable` and current selection are saved into a hidden portion of [Session State](/develop/concepts/architecture/session-state) called the Widget Metadata. When the user of your application interacts with the `st.selectbox` widget, the broswer sends the index of their selection to your Streamlit server. This index is used to determine which values from the original `options` list, _saved in the Widget Metadata from the previous page execution_, are returned to your application. @@ -273,7 +273,7 @@ As a final note, we used `@dataclass` in the example for this section to illustr ## Using `Enum` classes in Streamlit -The [`Enum`](https://docs.python.org/3/library/enum.html#enum.Enum) class from the Python standard library is a powerful way to define custom symbolic names that can be used as options for `st.multiselect` or `st.selectbox` in place of `str` values. +The [`Enum`](https://docs.python.org/3/develop/enum.html#enum.Enum) class from the Python standard library is a powerful way to define custom symbolic names that can be used as options for `st.multiselect` or `st.selectbox` in place of `str` values. For example, you might add the following to your streamlit page: @@ -305,6 +305,6 @@ When `enumCoercion` is enabled, Streamlit tries to recognize when you are using If Streamlit detects this, it will convert the widget's returned values to members of the `Enum` class defined in the latest script run. This is something we call automatic `Enum` coercion. -This behavior is [configurable](/library/advanced-features/configuration) via the `enumCoercion` setting in your Streamlit `config.toml` file. It is enabled by default, and may be disabled or set to a stricter set of matching criteria. +This behavior is [configurable](/develop/concepts/configuration) via the `enumCoercion` setting in your Streamlit `config.toml` file. It is enabled by default, and may be disabled or set to a stricter set of matching criteria. If you find that you still encounter issues with `enumCoercion` enabled, consider using the [custom class patterns](#patterns-to-define-your-custom-classes) described above, such as moving your `Enum` class definition to a separate module file. diff --git a/content/library/advanced-features/dataframes.md b/content/library/advanced-features/dataframes.md index 072775f36..21c5f8148 100644 --- a/content/library/advanced-features/dataframes.md +++ b/content/library/advanced-features/dataframes.md @@ -1,11 +1,11 @@ --- title: Dataframes -slug: /library/advanced-features/dataframes +slug: /develop/concepts/design/dataframes --- # Dataframes -Dataframes are a great way to display and edit data in a tabular format. Working with Pandas DataFrames and other tabular data structures is key to data science workflows. If developers and data scientists want to display this data in Streamlit, they have multiple options: `st.dataframe` and `st.data_editor`. If you want to solely display data in a table-like UI, [st.dataframe](/library/api-reference/data/st.dataframe) is the way to go. If you want to interactively edit data, use [st.data_editor](/library/api-reference/data/st.data_editor). We explore the use cases and advantages of each option in the following sections. +Dataframes are a great way to display and edit data in a tabular format. Working with Pandas DataFrames and other tabular data structures is key to data science workflows. If developers and data scientists want to display this data in Streamlit, they have multiple options: `st.dataframe` and `st.data_editor`. If you want to solely display data in a table-like UI, [st.dataframe](/develop/api-reference/data/st.dataframe) is the way to go. If you want to interactively edit data, use [st.data_editor](/develop/api-reference/data/st.data_editor). We explore the use cases and advantages of each option in the following sections. ## Display dataframes with st.dataframe @@ -48,7 +48,7 @@ In addition to Pandas DataFrames, `st.dataframe` also supports other common Pyth ## Edit data with st.data_editor -Streamlit supports editable dataframes via the `st.data_editor` command. Check out its API in [st.data_editor](/library/api-reference/data/st.data_editor). It shows the dataframe in a table, similar to `st.dataframe`. But in contrast to `st.dataframe`, this table isn't static! The user can click on cells and edit them. The edited data is then returned on the Python side. Here's an example: +Streamlit supports editable dataframes via the `st.data_editor` command. Check out its API in [st.data_editor](/develop/api-reference/data/st.data_editor). It shows the dataframe in a table, similar to `st.dataframe`. But in contrast to `st.dataframe`, this table isn't static! The user can click on cells and edit them. The edited data is then returned on the Python side. Here's an example: ```python df = pd.DataFrame( @@ -123,7 +123,7 @@ As developers, ensure the app is served with a valid, trusted certificate when u ### Access edited data -Sometimes, it is more convenient to know which cells have been changed rather than getting the entire edited dataframe back. Streamlit makes this easy through the use of [Session State](https://docs.streamlit.io/library/advanced-features/session-state). If a `key` parameter is set, Streamlit will store any changes made to the dataframe in Session State. +Sometimes, it is more convenient to know which cells have been changed rather than getting the entire edited dataframe back. Streamlit makes this easy through the use of [Session State](https://docs.streamlit.io/develop/concepts/architecture/session-state). If a `key` parameter is set, Streamlit will store any changes made to the dataframe in Session State. This snippet shows how you can access changed data using Session State: @@ -161,7 +161,7 @@ The data editor includes a feature that allows for bulk editing of cells. Simila ### Edit common data structures -Editing doesn't just work for Pandas DataFrames! You can also edit lists, tuples, sets, dictionaries, NumPy arrays, or Snowpark & PySpark DataFrames. Most data types will be returned in their original format. But some types (e.g. Snowpark and PySpark) are converted to Pandas DataFrames. To learn about all the supported types, read the [st.data_editor](/library/api-reference/data/st.data_editor) API. +Editing doesn't just work for Pandas DataFrames! You can also edit lists, tuples, sets, dictionaries, NumPy arrays, or Snowpark & PySpark DataFrames. Most data types will be returned in their original format. But some types (e.g. Snowpark and PySpark) are converted to Pandas DataFrames. To learn about all the supported types, read the [st.data_editor](/develop/api-reference/data/st.data_editor) API. For example, you can easily let the user add items to a list: @@ -202,19 +202,19 @@ st.data_editor({ ### Automatic input validation -The data editor includes automatic input validation to help prevent errors when editing cells. For example, if you have a column that contains numerical data, the input field will automatically restrict the user to only entering numerical data. This helps to prevent errors that could occur if the user were to accidentally enter a non-numerical value. Additional input validation can be configured through the [Column configuration API](/library/api-reference/data/st.column_config). Keep reading below for an overview of column configuration, including validation options. +The data editor includes automatic input validation to help prevent errors when editing cells. For example, if you have a column that contains numerical data, the input field will automatically restrict the user to only entering numerical data. This helps to prevent errors that could occur if the user were to accidentally enter a non-numerical value. Additional input validation can be configured through the [Column configuration API](/develop/api-reference/data/st.column_config). Keep reading below for an overview of column configuration, including validation options. ## Configuring columns -You can configure the display and editing behavior of columns in `st.dataframe` and `st.data_editor` via the [Column configuration API](/library/api-reference/data/st.column_config). We have developed the API to let you add images, charts, and clickable URLs in dataframe and data editor columns. Additionally, you can make individual columns editable, set columns as categorical and specify which options they can take, hide the index of the dataframe, and much more. +You can configure the display and editing behavior of columns in `st.dataframe` and `st.data_editor` via the [Column configuration API](/develop/api-reference/data/st.column_config). We have developed the API to let you add images, charts, and clickable URLs in dataframe and data editor columns. Additionally, you can make individual columns editable, set columns as categorical and specify which options they can take, hide the index of the dataframe, and much more. -Column configuration includes the following column types: Text, Number, Checkbox, Selectbox, Date, Time, Datetime, List, Link, Image, Line chart, Bar chart, and Progress. There is also a generic Column option. See the embedded app below to view these different column types. Each column type is individually previewed in the [Column configuration API](/library/api-reference/data/st.column_config) documentation. +Column configuration includes the following column types: Text, Number, Checkbox, Selectbox, Date, Time, Datetime, List, Link, Image, Line chart, Bar chart, and Progress. There is also a generic Column option. See the embedded app below to view these different column types. Each column type is individually previewed in the [Column configuration API](/develop/api-reference/data/st.column_config) documentation. ### Format values -A `format` parameter is available in column configuration for [Text](/library/api-reference/data/st.column_config/st.column_config.textcolumn), [Date](/library/api-reference/data/st.column_config/st.column_config.datecolumn), [Time](/library/api-reference/data/st.column_config/st.column_config.timecolumn), and [Datetime](/library/api-reference/data/st.column_config/st.column_config.datetimecolumn) columns. Chart-like columns can also be formatted. [Line chart](/library/api-reference/data/st.column_config/st.column_config.linechartcolumn) and [Bar chart](/library/api-reference/data/st.column_config/st.column_config.barchartcolumn) columns have a `y_min` and `y_max` parameters to set the vertical bounds. For a [Progress column](/library/api-reference/data/st.column_config/st.column_config.progresscolumn), you can declare the horizontal bounds with `min_value` and `max_value`. +A `format` parameter is available in column configuration for [Text](/develop/api-reference/data/st.column_config/st.column_config.textcolumn), [Date](/develop/api-reference/data/st.column_config/st.column_config.datecolumn), [Time](/develop/api-reference/data/st.column_config/st.column_config.timecolumn), and [Datetime](/develop/api-reference/data/st.column_config/st.column_config.datetimecolumn) columns. Chart-like columns can also be formatted. [Line chart](/develop/api-reference/data/st.column_config/st.column_config.linechartcolumn) and [Bar chart](/develop/api-reference/data/st.column_config/st.column_config.barchartcolumn) columns have a `y_min` and `y_max` parameters to set the vertical bounds. For a [Progress column](/develop/api-reference/data/st.column_config/st.column_config.progresscolumn), you can declare the horizontal bounds with `min_value` and `max_value`. ### Validate input @@ -260,7 +260,7 @@ In addition to column configuration, `st.dataframe` and `st.data_editor` have a `st.dataframe` and `st.data_editor` have been designed to theoretically handle tables with millions of rows thanks to their highly performant implementation using the glide-data-grid library and HTML canvas. However, the maximum amount of data that an app can realistically handle will depend on several other factors, including: -1. The maximum size of WebSocket messages: Streamlit's WebSocket messages are configurable via the `server.maxMessageSize` [config option](https://docs.streamlit.io/library/advanced-features/configuration#view-all-configuration-options), which limits the amount of data that can be transferred via the WebSocket connection at once. +1. The maximum size of WebSocket messages: Streamlit's WebSocket messages are configurable via the `server.maxMessageSize` [config option](https://docs.streamlit.io/develop/concepts/configuration#view-all-configuration-options), which limits the amount of data that can be transferred via the WebSocket connection at once. 2. The server memory: The amount of data that your app can handle will also depend on the amount of memory available on your server. If the server's memory is exceeded, the app may become slow or unresponsive. 3. The user's browser memory: Since all the data needs to be transferred to the user's browser for rendering, the amount of memory available on the user's device can also affect the app's performance. If the browser's memory is exceeded, it may crash or become unresponsive. @@ -272,7 +272,7 @@ When handling large datasets with more than 150,000 rows, Streamlit applies addi - Streamlit casts all column names to strings internally, so `st.data_editor` will return a DataFrame where all column names are strings. - The dataframe toolbar is not currently configurable. -- While Streamlit's data editing capabilities offer a lot of functionality, editing is enabled for a limited set of column types ([TextColumn](/library/api-reference/data/st.column_config/st.column_config.textcolumn), [NumberColumn](/library/api-reference/data/st.column_config/st.column_config.numbercolumn), [LinkColumn](/library/api-reference/data/st.column_config/st.column_config.linkcolumn), [CheckboxColumn](/library/api-reference/data/st.column_config/st.column_config.checkboxcolumn), [SelectboxColumn](/library/api-reference/data/st.column_config/st.column_config.selectboxcolumn), [DateColumn](/library/api-reference/data/st.column_config/st.column_config.datecolumn), [TimeColumn](/library/api-reference/data/st.column_config/st.column_config.timecolumn), and [DatetimeColumn](/library/api-reference/data/st.column_config/st.column_config.datetimecolumn)). We are actively working on supporting editing for other column types as well, such as images, lists, and charts. +- While Streamlit's data editing capabilities offer a lot of functionality, editing is enabled for a limited set of column types ([TextColumn](/develop/api-reference/data/st.column_config/st.column_config.textcolumn), [NumberColumn](/develop/api-reference/data/st.column_config/st.column_config.numbercolumn), [LinkColumn](/develop/api-reference/data/st.column_config/st.column_config.linkcolumn), [CheckboxColumn](/develop/api-reference/data/st.column_config/st.column_config.checkboxcolumn), [SelectboxColumn](/develop/api-reference/data/st.column_config/st.column_config.selectboxcolumn), [DateColumn](/develop/api-reference/data/st.column_config/st.column_config.datecolumn), [TimeColumn](/develop/api-reference/data/st.column_config/st.column_config.timecolumn), and [DatetimeColumn](/develop/api-reference/data/st.column_config/st.column_config.datetimecolumn)). We are actively working on supporting editing for other column types as well, such as images, lists, and charts. - Almost all editable datatypes are supported for index editing. However, `pandas.CategoricalIndex` and `pandas.MultiIndex` are not supported for editing. - Sorting is not supported for `st.data_editor` when `num_rows="dynamic"`. - Sorting is deactivated to optimize performance on large datasets with more than 150,000 rows. diff --git a/content/library/advanced-features/elements-and-ui/_index.md b/content/library/advanced-features/elements-and-ui/_index.md new file mode 100644 index 000000000..2ca881b04 --- /dev/null +++ b/content/library/advanced-features/elements-and-ui/_index.md @@ -0,0 +1,50 @@ +--- +title: App design concepts and considerations +slug: /develop/concepts/design +--- + +# App design concepts and considerations + + + + + +
    Animate and update elements
    + +Understand how to create dynamic, animated content or update elements without rerunning your app. + +
    + + + +
    Button behavior and examples
    + +Understand how buttons work with explanations and examples to avoid common mistakes. + +
    + + + +
    Dataframes
    + +Dataframes are a great way to display and edit data in a tabular format. Understand the UI and options available in Streamlit. + +
    + + + +
    Using custom Python classes in your Streamlit app
    + +Understand the impact of defining your own Python classes within Streamlit's rerun model. + +
    + + + +
    Working with timezones
    + +Understand how to localize time to your users. + +
    + +
    diff --git a/content/library/advanced-features/execution-model/_index.md b/content/library/advanced-features/execution-model/_index.md new file mode 100644 index 000000000..a5d271478 --- /dev/null +++ b/content/library/advanced-features/execution-model/_index.md @@ -0,0 +1,66 @@ +--- +title: Working with Streamlit's execution model +slug: /develop/concepts/architecture +--- + +# Working with Streamlit's execution model + + + + + +
    Run your app
    + +Understand how to start your Streamlit app. + +
    + + + +
    Streamlit's architecture
    + +Understand Streamlit's server-client architecture and related considerations. + +
    + + + +
    The app chrome
    + +Every Streamlit app has a few widgets in the top right to help you as you develop your app and help your users as they view your app. This is called the app chrome. + +
    + + + +
    Caching
    + +Make your app performant by caching results to avoid unecessary recomputation with each rerun. + +
    + + + +
    Session State
    + +Manage your app's statefulness with Session State. + +
    + + + +
    Forms
    + +Use forms to isolate user input and prevent unnecessary app reruns. + +
    + + + +
    Widget behavior
    + +Understand how widgets work in detail. + +
    + +
    diff --git a/content/library/advanced-features/execution-model/architecture.md b/content/library/advanced-features/execution-model/architecture.md new file mode 100644 index 000000000..a3963042f --- /dev/null +++ b/content/library/advanced-features/execution-model/architecture.md @@ -0,0 +1,25 @@ +--- +title: Understanding Streamlit's server-client architecture +slug: /develop/concepts/architecture/architecture +--- + +# Understanding Streamlit's server-client architecture + +Streamlit apps have a server-client structure. The Python backend of your app is the server. The frontend you view through a browswer is the client. When you develop an app locally, your computer runs both the server and the client. If someone views your app across a local or global network, the server and client run on different machines. If you intend to share or deploy your app, it's important to understand this server-client structure to avoid common pitfalls. + +## Python backend (server) + +When you execute the command `streamlit run your_app.py`, your computer uses Python to start up a Streamlit server. This server is the brains of your app and performs the computations for all users who view your app. Whether users view your app across a local network or the internet, the Streamlit server runs on the one machine where the app was initialized with `streamlit run`. The machine running your Streamlit server is also called a host. + +## Browser frontend (client) + +When someone views your app through a browser, their device is a Streamlit client. When you view your app from the same computer where you are running or developing your app, then server and client are coincidentally running on the same machine. However, when users view your app across a local network or the internet, the client runs on a different machine from the server. + +## Server-client impact on app design + +Keep in mind the following considerations when building your Streamlit app: + +- The computer running or hosting your Streamlit app is responsible for providing the compute and and storage necessary to run your app for all users and must be sized appropriately to handle concurrent users. +- Your app will not have access to a user's files, directories, or OS. Your app can only work with specific files a user has uploaded to your app through a widget like `st.file_uploader`. +- If your app communicates with any peripheral devices (like cameras), you must use Streamlit commands or custom components that will access those devices _through the user's browser_ and correctly communicate between the client (frontend) and server (backend). +- If your app opens or uses any program or process outside of Python, they will run on the server. For example, you may want to use `webrowser` to open a browser for the user, but this will not work as expected when viewing your app over a network; it will open a browser on the Streamlit server, unseen by the user. diff --git a/content/library/advanced-features/experimental-cache-primitives.md b/content/library/advanced-features/experimental-cache-primitives.md index 8347c2d4b..4cfcecfa7 100644 --- a/content/library/advanced-features/experimental-cache-primitives.md +++ b/content/library/advanced-features/experimental-cache-primitives.md @@ -1,11 +1,11 @@ --- title: Experimental cache primitives -slug: /library/advanced-features/experimental-cache-primitives +slug: /develop/concepts/architecture/experimental-cache-primitives --- -The experimental cache primitives described on this page were deprecated in version 1.18.0. Use [`st.cache_data`](/library/api-reference/performance/st.cache_data) or [`st.cache_resource`](/library/api-reference/performance/st.cache_resource) instead. Learn more in [Caching](/library/advanced-features/caching). +The experimental cache primitives described on this page were deprecated in version 1.18.0. Use [`st.cache_data`](/develop/api-reference/caching-and-state/st.cache_data) or [`st.cache_resource`](/develop/api-reference/caching-and-state/st.cache_resource) instead. Learn more in [Caching](/develop/concepts/architecture/caching). @@ -15,11 +15,11 @@ The experimental cache primitives described on this page were deprecated in vers Streamlit's unique execution model is a part of what makes it a joy to use: your code executes from top to bottom like a simple script for every interaction. There's no need to think about models, views, controllers, or anything of the sort. -Whenever your code re-executes, a decorator called [`@st.cache`](/library/api-reference/performance/st.cache)—which is a powerful primitive for memoization and state storage capabilities—provides a caching mechanism that allows your app to stay performant even when loading data from the web, manipulating large datasets, or performing expensive computations. +Whenever your code re-executes, a decorator called [`@st.cache`](/develop/api-reference/caching-and-state/st.cache)—which is a powerful primitive for memoization and state storage capabilities—provides a caching mechanism that allows your app to stay performant even when loading data from the web, manipulating large datasets, or performing expensive computations. -However, we've found that [`@st.cache`](/library/advanced-features/caching) is hard to use and not fast. You're either faced with cryptic errors like `InternalHashError` or `UnhashableTypeError`. Or you need to understand concepts like [`hash_funcs`](/library/advanced-features/caching#the-hash_funcs-parameter) and [`allow_output_mutation`](/library/advanced-features/caching#example-1-pass-a-database-connection-around). +However, we've found that [`@st.cache`](/develop/concepts/architecture/caching) is hard to use and not fast. You're either faced with cryptic errors like `InternalHashError` or `UnhashableTypeError`. Or you need to understand concepts like [`hash_funcs`](/develop/concepts/architecture/caching#the-hash_funcs-parameter) and [`allow_output_mutation`](/develop/concepts/architecture/caching#example-1-pass-a-database-connection-around). -Our solutions include two new primitives: [**`st.experimental_memo`**](/library/api-reference/performance/st.experimental_memo) and [**`st.experimental_singleton`**](/library/api-reference/performance/st.experimental_singleton). They're conceptually simpler and much, much faster. In some of our internal tests on caching large dataframes, `@st.experimental_memo` has outperformed `@st.cache` by an order of magnitude. That's over 10X faster! 🚀 +Our solutions include two new primitives: [**`st.experimental_memo`**](/develop/api-reference/caching-and-state/st.experimental_memo) and [**`st.experimental_singleton`**](/develop/api-reference/caching-and-state/st.experimental_singleton). They're conceptually simpler and much, much faster. In some of our internal tests on caching large dataframes, `@st.experimental_memo` has outperformed `@st.cache` by an order of magnitude. That's over 10X faster! 🚀 Let's take a look at the use-cases these _two_ experimental APIs serve, and how they're a significant improvement over `@st.cache`. @@ -39,7 +39,7 @@ While `@st.cache` tries to solve two very different problems simultaneously (cac ### `@st.experimental_memo` -Use [`@st.experimental_memo`](/library/api-reference/performance/st.experimental_memo) to store expensive computation which can be "cached" or "memoized" in the traditional sense. It has almost the exact same API as the existing `@st.cache`, so you can often blindly replace one for the other: +Use [`@st.experimental_memo`](/develop/api-reference/caching-and-state/st.experimental_memo) to store expensive computation which can be "cached" or "memoized" in the traditional sense. It has almost the exact same API as the existing `@st.cache`, so you can often blindly replace one for the other: ```python import streamlit as st @@ -97,7 +97,7 @@ def get_page(_sessionmaker, page_size, page): ### `@st.experimental_singleton` -[`@st.experimental_singleton`](/library/api-reference/performance/st.experimental_singleton) is a key-value store that's shared across all sessions of a Streamlit app. It's great for storing heavyweight singleton objects across sessions (like TensorFlow/Torch/Keras sessions and/or database connections). +[`@st.experimental_singleton`](/develop/api-reference/caching-and-state/st.experimental_singleton) is a key-value store that's shared across all sessions of a Streamlit app. It's great for storing heavyweight singleton objects across sessions (like TensorFlow/Torch/Keras sessions and/or database connections). Example usage: @@ -164,11 +164,11 @@ Pressing the "Clear Square" button will clear `square()`'s memoized values. Pres In summary: - Any function annotated with `@st.experimental_memo` or `@st.experimental_singleton` gets its own `clear()` function automatically. -- Additionally, you can use [`st.experimental_memo.clear()`](/library/api-reference/performance/st.experimental_memo.clear) and [`st.experimental_singleton.clear()`](/library/api-reference/performance/st.experimental_singleton.clear) to clear _all_ memo and singleton caches, respectively. +- Additionally, you can use [`st.experimental_memo.clear()`](/develop/api-reference/caching-and-state/st.experimental_memo.clear) and [`st.experimental_singleton.clear()`](/develop/api-reference/caching-and-state/st.experimental_singleton.clear) to clear _all_ memo and singleton caches, respectively. -The commands are **experimental**, so they're governed by our [experimental API process](/library/advanced-features/prerelease#experimental). +The commands are **experimental**, so they're governed by our [experimental API process](/develop/quick-reference/prerelease#experimental). diff --git a/content/library/advanced-features/forms.md b/content/library/advanced-features/forms.md index b187c04ec..f92b81af7 100644 --- a/content/library/advanced-features/forms.md +++ b/content/library/advanced-features/forms.md @@ -1,11 +1,11 @@ --- title: Using forms -slug: /library/advanced-features/forms +slug: /develop/concepts/architecture/forms --- # Using forms -When you don't want to rerun your script with each input made by a user, [`st.form`](/library/api-reference/control-flow/st.form) is here to help! Forms make it easy to batch user input into a single rerun. This guide to using forms provides examples and explains how users interact with forms. +When you don't want to rerun your script with each input made by a user, [`st.form`](/develop/api-reference/execution-flow/st.form) is here to help! Forms make it easy to batch user input into a single rerun. This guide to using forms provides examples and explains how users interact with forms. ## Example @@ -99,7 +99,7 @@ st.write(my_color) ## Forms are containers -When `st.form` is called, a container is created on the frontend. You can write to that container like you do with other [container elements](/library/api-reference/layout). That is, you can use Python's `with` statement as shown in the example above, or you can assign the form container to a variable and call methods on it directly. Additionally, you can place `st.form_submit_button` anywhere in the form container. +When `st.form` is called, a container is created on the frontend. You can write to that container like you do with other [container elements](/develop/api-reference/layout). That is, you can use Python's `with` statement as shown in the example above, or you can assign the form container to a variable and call methods on it directly. Additionally, you can place `st.form_submit_button` anywhere in the form container. ```python import streamlit as st diff --git a/content/library/advanced-features/https.md b/content/library/advanced-features/https.md index 93a024e26..7728f47b2 100644 --- a/content/library/advanced-features/https.md +++ b/content/library/advanced-features/https.md @@ -1,15 +1,15 @@ --- title: HTTPS support -slug: /library/advanced-features/https-support +slug: /develop/concepts/configuration/https-support --- # HTTPS support Many apps need to be accessed with SSL / [TLS](https://en.wikipedia.org/wiki/Transport_Layer_Security) 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](/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](/knowledge-base/tutorials/deploy). +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](/deploy/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](/deploy/tutorials). -To terminate SSL in your Streamlit app, you must configure `server.sslCertFile` and `server.sslKeyFile`. Learn how to set config options in [Configuration](/library/advanced-features/configuration). +To terminate SSL in your Streamlit app, you must configure `server.sslCertFile` and `server.sslKeyFile`. Learn how to set config options in [Configuration](/develop/concepts/configuration). ## Details on usage diff --git a/content/library/advanced-features/multipage-apps/_index.md b/content/library/advanced-features/multipage-apps/_index.md new file mode 100644 index 000000000..93cff8d9e --- /dev/null +++ b/content/library/advanced-features/multipage-apps/_index.md @@ -0,0 +1,143 @@ +--- +title: Creating multipage apps using the `pages/` directory +slug: /develop/concepts/multipage-apps/pages-directory +description: Streamlit provides a simple way to create multipage apps. +--- + +# Creating multipage apps using the `pages/` directory + +As your app grows large, it becomes useful to organize your script into multiple pages. This makes your app easier to manage as a developer and easier to navigate as a user. Streamlit provides a frictionless way to create multipage apps. Pages are automatically shown in a navigation widget inside your app's sidebar. If a user clicks on a page in the sidebar, Streamlit navigates to that page without reloading the frontend — making app browsing incredibly fast! In this guide, let’s learn how to create multipage apps. + +## Structuring your multipage app + +Streamlit identifies pages in a multipage app by directory structure and filenames. The file you pass to `streamlit run` is called your entrypoint file. This is your app's homepage. When you have a `pages/` directory next to your entrypoint file, Streamlit will identify each Python file within it as a page. The following example has three pages. `your_homepage.py` is the entrypoint file and homepage. + +``` +your_working_directory/ +├── pages/ +│ ├── a_page.py +│ └── another_page.py +└── your_homepage.py +``` + +Run your multipage app just like you would for a single-page app. Pass your entrypoint file to `streamlit run`. + +``` +streamlit run your_homepage.py +``` + +Only `.py` files in the `pages/` directory will be identified as pages. Streamlit ignores all other files in the `pages/` directory and its subdirectories. Streamlit also ignores Python files in subdirectories of `pages/`. + +Keep reading to learn how filenames are displayed and ordered in your app's navigation. + +## Naming and ordering your pages + +The entrypoint file is your app's homepage and the first page users will see when visiting your app. Once you've added pages to your app, the entrypoint file appears as the topmost page in the sidebar. Streamlit determines the page label and ordering of each page from your filenames. Labels may differ from the page title set in [`st.set_page_config`](/develop/api-reference/configuration/st.set_page_config). + +### Filenames for pages + +Filenames are composed of four different parts as follows: + +1. `number`. A non-negative integer. +2. `separator`. Any combination of underscore (`"_"`), dash (`"-"`), and space (`" "`). +3. `label`. Everything up to, but not including, `".py"`. +4. `".py"` + +### How Streamlit converts filenames into page labels + +Streamlit displays page labels as follows: + +1. If your filename contains a `label`, Streamlit displays the `label` in the left navigation. Any underscores within the page's `label` are treated as spaces. +2. If your filename contains a `number` but does not contain a `label`, Streamlit displays the `number` instead. +3. If your filename contains only a `separator` with no `number` and no `label`, Streamlit will not display the page in the sidebar navigation. + +The following filenames would all display as "Awesome homepage" in the sidebar navigation. + +- `"Awesome homepage.py"` +- `"Awesome_homepage.py"` +- `"02Awesome_homepage.py"` +- `"--Awesome_homepage.py"` +- `"1_Awesome_homepage.py"` +- `"33 - Awesome homepage.py"` + +### How pages are sorted in the sidebar + +The entrypoint file is always displayed first. The remaining pages are sorted as follows: + +- Files that have a `number` appear before files without a `number`. +- Files are sorted based on the `number` (if any), followed by the `label` (if any). +- When files are sorted, Streamlit treats the `number` as an actual number rather than a string. So `03` is the same as `3`. + +This table shows examples of filenames and their corresponding labels, sorted by the order in which they appear in the sidebar. + +**Examples**: + +| **Filename** | **Rendered label** | +| :------------------------ | :----------------- | +| `1 - first page.py` | first page | +| `12 monkeys.py` | monkeys | +| `123.py` | 123 | +| `123_hello_dear_world.py` | hello dear world | +| `_12 monkeys.py` | 12 monkeys | + + + +Emojis can be used to make your page names more fun! For example, a file named `🏠_Home.py` will create a page titled "🏠 Home" in the sidebar. When adding emojis to filenames, it’s best practice to include a numbered prefix to make autocompletion in your terminal easier. Terminal-autocomplete can get confused by unicode (which is how emojis are represented). + + + +## Navigating between pages + +Pages are automatically shown in a sidebar navigation UI. When a user clicks on a page in the sidebar UI, Streamlit navigates to that page without reloading the entire frontend — making app browsing incredibly fast! Optionally, you can hide the default navigation UI and build your own with [`st.page_link`](/develop/api-reference/widgets/st.page_link). For more information, see [Build a custom navigation menu with `st.page_link`](/develop/tutorials/multipage/st.page_link-nav). + +If you need to programmatically switch pages, use [`st.switch_page`](/develop/api-reference/navigation/st.switch_page). + +Users can also navigate between pages using URLs. Pages have their own URLs, defined by the file's `label`. When multiple files have the same `label`, Streamlit picks the first one (based on the ordering [described above](#how-pages-are-sorted-in-the-sidebar)). Users can view a specific page by visiting the page's URL. + + + +Navigating between pages by URL creates a new browser session and clears `st.session_state`. In particular, clicking markdown links to other +pages resets `st.session_state`. In order to retain values in `st.session_state`, a user must use the sidebar navigation or other Streamlit +widgets to switch pages. + + + +If a user tries to access a URL for a page that does not exist, they will see a modal like the one below, saying the user has requested a page that was not found in the app’s `pages/` directory. + + + +## Notes and limitations + +- Pages support run-on-save. + - When you update a page while your app is running, this causes a rerun for users currently viewing that exact page. + - When you update a page while your app is running, the app will not automatically rerun for users currently viewing a different page. +- While your app is running, adding or deleting a page updates the sidebar navigation immediately. +- [`st.set_page_config`](/develop/api-reference/configuration/st.set_page_config) works at the page level. + - When you set `title` or `favicon` using `st.set_page_config`, this applies to the current page only. + - When you set `layout` using `st.set_page_config`, the setting will remain for the session until changed by another call to `st.set_page_config`. If you use `st.set_page_config` to set `layout`, it's recommended to call it on _all_ pages. +- Pages share the same Python modules globally: + + ```python + # page1.py + import foo + foo.hello = 123 + + # page2.py + import foo + st.write(foo.hello) # If page1 already executed, this writes 123 + ``` + +- Pages share the same [st.session_state](/develop/concepts/architecture/session-state): + + ```python + # page1.py + import streamlit as st + if "shared" not in st.session_state: + st.session_state["shared"] = True + + # page2.py + import streamlit as st + st.write(st.session_state["shared"]) # If page1 already executed, this writes True + ``` + +You now have a solid understanding of multipage apps. You've learned how to structure apps, define pages, and navigate between pages in the user interface. It's time to [create your first multipage app](/get-started/tutorials/create-a-multipage-app)! 🥳 diff --git a/content/library/advanced-features/multipage-apps/_multipage-apps.md b/content/library/advanced-features/multipage-apps/_multipage-apps.md deleted file mode 100644 index 36a985423..000000000 --- a/content/library/advanced-features/multipage-apps/_multipage-apps.md +++ /dev/null @@ -1,138 +0,0 @@ ---- -title: Multipage apps -slug: /library/advanced-features/multipage-apps -description: Streamlit provides a simple way to create multipage apps. ---- - -# Multipage apps - -As apps grow large, it becomes useful to organize them into multiple pages. This makes the app easier to manage as a developer and easier to navigate as a user. Streamlit provides a frictionless way to create multipage apps. Pages are automatically shown in a nice navigation widget inside the app sidebar, and clicking on a page will navigate to the page without reloading the frontend — making app browsing incredibly fast! In this guide, let’s learn how to create multipage apps. - -## Structuring multipage apps - -Let's understand what it takes to create multipage apps — including how to define pages, structure and run multipage apps, and navigate between pages in the user interface. Once you've understood the basics, you can jump right into a tutorial to [Create a multipage app](/get-started/tutorials/create-a-multipage-app). - -## Run a multipage app - -Running a multipage app is identical to running a single-page app. The command to run a multipage app is: - -```python -streamlit run [entrypoint file] -``` - -The "entrypoint file" is the first page the app will show to the user. Once you have added pages to your app, the entrypoint file appears as the top-most page in the sidebar. You can think of the entrypoint file as your app's "main page". For example, say your entrypoint file is `Home.py`. Then, to run your app, you can run `streamlit run Home.py`. This will start your app and execute the code in `Home.py`. - -## Adding pages - -Once you've created your entrypoint file, you can add pages by creating `.py` files in a `pages/` directory relative to your entrypoint file. For example, if your entrypoint file is `Home.py`, then you can create a `pages/About.py` file to define the "About" page. Here's a valid directory structure for a multipage app: - -``` -Home.py # This is the file you run with "streamlit run" -└─── pages/ - └─── About.py # This is a page - └─── 2_Page_two.py # This is another page - └─── 3_😎_three.py # So is this -``` - - - -When adding emojis to filenames, it’s best practice to include a numbered-prefix to make autocompletion in your terminal easier. Terminal-autocomplete can get confused by unicode (which is how emojis are represented). - - - -Pages are defined as `.py` files in a `pages/` directory. The filenames of pages are transformed to page names in the sidebar based on the the rules in the [section below](#how-pages-are-labeled-and-sorted-in-the-ui). For example, the `About.py` file will appear as "About" in the sidebar, `2_Page_two.py` appears as "Page two", and `3_😎_three.py` appears as “😎 three": - -![Directory structure](/images/mpa-add-pages.png) - -Only `.py` files in the `pages/` directory will be loaded as pages. Streamlit ignores all other files in the `pages/` directory and subdirectories. - -## How pages are labeled and sorted in the UI - -Page labels in the sidebar UI are generated from filenames. They may differ from the page title set in [`st.set_page_config`](/library/api-reference/utilities/st.set_page_config). Let's learn what constitutes a valid filename for a page, how pages are displayed in the sidebar, and how pages are sorted. - -### Valid filenames for pages - -Filenames are composed of four different parts: - -1. A `number` — if the file is prefixed with a number. -2. A separator — could be `_`, `-`, space, or any combination thereof. -3. A `label` — which is everything up to, but not including, `.py`. -4. The extension — which is always `.py`. - -### How pages are displayed in the sidebar - -What is displayed in the sidebar is the `label` part of the filename: - -- If there's no `label`, Streamlit uses the `number` as the label. -- In the UI, Streamlit beautifies the `label` by replacing `_` with space. - -### How pages are sorted in the sidebar - -Sorting considers numbers in the filename to be actual numbers (_integers_): - -- Files that have a `number` appear before files without a `number`. -- Files are sorted based on the `number` (if any), followed by the `title` (if any). -- When files are sorted, Streamlit treats the `number` as an actual number rather than a string. So `03` is the same as `3`. - -This table shows examples of filenames and their corresponding labels, sorted by the order in which they appear in the sidebar. - -**Examples**: - -| **Filename** | **Rendered label** | -| :------------------------ | :----------------- | -| `1 - first page.py` | first page | -| `12 monkeys.py` | monkeys | -| `123.py` | 123 | -| `123_hello_dear_world.py` | hello dear world | -| `_12 monkeys.py` | 12 monkeys | - - - -Emojis can be used to make your page names more fun! For example, a file named `🏠_Home.py` will create a page titled "🏠 Home" in the sidebar. - - - -## Navigating between pages - -Pages are automatically shown in a nice navigation UI inside the app's sidebar. When you click on a page in the sidebar UI, Streamlit navigates to that page without reloading the entire frontend — making app browsing incredibly fast! - -You can also navigate between pages using URLs. Pages have their own URLs, defined by the file's `label`. When multiple files have the same `label`, Streamlit picks the first one (based on the ordering [described above](#how-pages-are-sorted-in-the-sidebar)). Users can view a specific page by visiting the page's URL. - -If a user tries to access a URL for a page that does not exist, they will see a modal like the one below, saying the user has requested a page that was not found in the app’s pages/ directory. - - - -## Notes - -- Pages support [magic commands](/library/api-reference/write-magic/magic). -- Pages support run-on-save. Additionally, when you save a page, this causes a rerun for users currently viewing that exact page. -- Adding or deleting a page causes the UI to update immediately. -- Updating pages in the sidebar does not rerun the script. -- `st.set_page_config` works at the page level. When you set a title or favicon using [st.set_page_config](/library/api-reference/utilities/st.set_page_config), this applies to the current page only. -- Pages share the same Python modules globally: - - ```python - # page1.py - import foo - foo.hello = 123 - - # page2.py - import foo - st.write(foo.hello) # If page1 already executed, this should write 123 - ``` - -- Pages share the same [st.session_state](/library/advanced-features/session-state): - - ```python - # page1.py - import streamlit as st - if "shared" not in st.session_state: - st.session_state["shared"] = True - - # page2.py - import streamlit as st - st.write(st.session_state["shared"]) - # If page1 already executed, this should write True - ``` - -You now have a solid understanding of multipage apps. You've learned how to structure apps, define pages, and navigate between pages in the user interface. It's time to [create your first multipage app](/get-started/tutorials/create-a-multipage-app)! 🥳 diff --git a/content/library/advanced-features/multipage-apps/_new_index.md b/content/library/advanced-features/multipage-apps/_new_index.md new file mode 100644 index 000000000..c5426286b --- /dev/null +++ b/content/library/advanced-features/multipage-apps/_new_index.md @@ -0,0 +1,19 @@ +--- +title: Multipage apps +slug: /develop/concepts/multipage-apps +description: Streamlit provides a simple way to create multipage apps. +--- + +# Multipage apps + + + + + +
    Creating multipage apps using the pages/ directory (MPA v1)
    + +Streamlit provides a frictionless way to create multipage apps. Place additional Python files in a `pages/` directory alongside your entrypoint file and pages are automatically shown in a navigation widget inside your app's sidebar. + +
    + +
    diff --git a/content/library/advanced-features/multipage-apps/custom-navigation.md b/content/library/advanced-features/multipage-apps/custom-navigation.md index 351c8d633..cc26d30cd 100644 --- a/content/library/advanced-features/multipage-apps/custom-navigation.md +++ b/content/library/advanced-features/multipage-apps/custom-navigation.md @@ -1,12 +1,12 @@ --- -title: Create custom navigation menus -slug: /library/advanced-features/multipage-apps/custom-navigation +title: Build a custom navigation menu with `st.page_link` +slug: /develop/tutorials/multipage/st.page_link-nav description: Streamlit makes it easy to build a custom navigation menu in your multipage app. --- -# Create custom navigation menus +# Build a custom navigation menu with `st.page_link` -Streamlit lets you build custom navigation menus and elements with `st.page_link`. Introduced in Streamlit version 1.31.0, `st.page_link` can link to other pages in your multipage app or to external sites. When linked to another page in your app, `st.page_link` will show a highlight effect to indicate the current page. When combined with the [`client.showSidebarNavigation`](/library/advanced-features/configuration#client) configuration option, you can build sleek, dynamic navigation in your app. +Streamlit lets you build custom navigation menus and elements with `st.page_link`. Introduced in Streamlit version 1.31.0, `st.page_link` can link to other pages in your multipage app or to external sites. When linked to another page in your app, `st.page_link` will show a highlight effect to indicate the current page. When combined with the [`client.showSidebarNavigation`](/develop/concepts/configuration#client) configuration option, you can build sleek, dynamic navigation in your app. ## Prerequisites diff --git a/content/library/advanced-features/prerelease-features.md b/content/library/advanced-features/prerelease-features.md index 8a0b4d0b3..28dd66051 100644 --- a/content/library/advanced-features/prerelease-features.md +++ b/content/library/advanced-features/prerelease-features.md @@ -1,6 +1,6 @@ --- title: Pre-release features -slug: /library/advanced-features/prerelease +slug: /develop/quick-reference/prerelease --- # Pre-release features diff --git a/content/library/advanced-features/secrets-management.md b/content/library/advanced-features/secrets-management.md index 92cca188c..3e3521f4d 100644 --- a/content/library/advanced-features/secrets-management.md +++ b/content/library/advanced-features/secrets-management.md @@ -1,6 +1,6 @@ --- title: Secrets management -slug: /library/advanced-features/secrets-management +slug: /develop/concepts/connections/secrets-management --- # Secrets management @@ -70,7 +70,7 @@ st.write( -You can access `st.secrets` via attribute notation (e.g. `st.secrets.key`), in addition to key notation (e.g. `st.secrets["key"]`) — like [st.session_state](/library/api-reference/session-state). +You can access `st.secrets` via attribute notation (e.g. `st.secrets.key`), in addition to key notation (e.g. `st.secrets["key"]`) — like [st.session_state](/develop/api-reference/caching-and-state/st.session_state). @@ -111,4 +111,4 @@ Here are some common errors you might encounter when using secrets management. ### Use secrets on Streamlit Community Cloud -When you deploy your app to [Streamlit Community Cloud](https://streamlit.io/cloud), you can use the same secrets management workflow as you would locally. However, you'll need to also set up your secrets in the Community Cloud Secrets Management console. Learn how to do so via the Cloud-specific [Secrets management](/streamlit-community-cloud/deploy-your-app/secrets-management) documentation. +When you deploy your app to [Streamlit Community Cloud](https://streamlit.io/cloud), you can use the same secrets management workflow as you would locally. However, you'll need to also set up your secrets in the Community Cloud Secrets Management console. Learn how to do so via the Cloud-specific [Secrets management](/deploy/streamlit-community-cloud/deploy-your-app/secrets-management) documentation. diff --git a/content/library/advanced-features/security-reminders.md b/content/library/advanced-features/security-reminders.md index 6f7983fdf..d5b596da8 100644 --- a/content/library/advanced-features/security-reminders.md +++ b/content/library/advanced-features/security-reminders.md @@ -1,6 +1,6 @@ --- title: Security reminders -slug: /library/advanced-features/security-reminders +slug: /develop/concepts/connections/security-reminders --- # Security reminders @@ -11,7 +11,7 @@ Never save usernames, passwords, or security keys directly in your code or commi ### Use environment variables -Avoid putting sensitve information in your code by using environment variables. Be sure to check out [`st.secrets`](/library/advanced-features/secrets-management). Research any platform you use to follow their security best practices. If you use Streamlit Community Cloud, [Secrets management](/streamlit-community-cloud/deploy-your-app/secrets-management) allows you save environment variables and store secrets outside of your code. +Avoid putting sensitve information in your code by using environment variables. Be sure to check out [`st.secrets`](/develop/concepts/connections/secrets-management). Research any platform you use to follow their security best practices. If you use Streamlit Community Cloud, [Secrets management](/deploy/streamlit-community-cloud/deploy-your-app/secrets-management) allows you save environment variables and store secrets outside of your code. ### Keep `.gitignore` updated @@ -19,7 +19,7 @@ If you use any sensitive or private information during development, make sure th ## Pickle warning -Streamlit's [`st.cache_data`](/library/advanced-features/caching#stcache_data) and [`st.session_state`](/library/advanced-features/session-state#serializable-session-state) implicitly use the `pickle` module, which is known to be insecure. It is possible to construct malicious pickle data that will execute arbitrary code during unpickling. Never load data that could have come from an untrusted source in an unsafe mode or that could have been tampered with. **Only load data you trust**. +Streamlit's [`st.cache_data`](/develop/concepts/architecture/caching#stcache_data) and [`st.session_state`](/develop/concepts/architecture/session-state#serializable-session-state) implicitly use the `pickle` module, which is known to be insecure. It is possible to construct malicious pickle data that will execute arbitrary code during unpickling. Never load data that could have come from an untrusted source in an unsafe mode or that could have been tampered with. **Only load data you trust**. -- When using `st.cache_data`, anything your function returns is pickled and stored, then unpickled on retrieval. Ensure your cached functions return trusted values. This warning also applies to [`st.cache`](/library/api-reference/performance/st.cache) (deprecated). -- When the `runner.enforceSerializableSessionState` [configuration option](<(/library/advanced-features/configuration#runner)>) is set to `true`, ensure all data saved and retrieved from Session State is trusted. +- When using `st.cache_data`, anything your function returns is pickled and stored, then unpickled on retrieval. Ensure your cached functions return trusted values. This warning also applies to [`st.cache`](/develop/api-reference/caching-and-state/st.cache) (deprecated). +- When the `runner.enforceSerializableSessionState` [configuration option](<(/develop/concepts/configuration#runner)>) is set to `true`, ensure all data saved and retrieved from Session State is trusted. diff --git a/content/library/advanced-features/session-state.md b/content/library/advanced-features/session-state.md index 7f695a322..528731a5e 100644 --- a/content/library/advanced-features/session-state.md +++ b/content/library/advanced-features/session-state.md @@ -1,6 +1,6 @@ --- title: Add statefulness to apps -slug: /library/advanced-features/session-state +slug: /develop/concepts/architecture/session-state --- # Add statefulness to apps @@ -9,11 +9,11 @@ slug: /library/advanced-features/session-state We define access to a Streamlit app in a browser tab as a **session**. For each browser tab that connects to the Streamlit server, a new session is created. Streamlit reruns your script from top to bottom every time you interact with your app. Each reruns takes place in a blank slate: no variables are shared between runs. -Session State is a way to share variables between reruns, for each user session. In addition to the ability to store and persist state, Streamlit also exposes the ability to manipulate state using Callbacks. Session state also persists across pages inside a [multipage app](/library/advanced-features/multipage-apps). +Session State is a way to share variables between reruns, for each user session. In addition to the ability to store and persist state, Streamlit also exposes the ability to manipulate state using Callbacks. Session state also persists across pages inside a [multipage app](/develop/concepts/multipage-apps). In this guide, we will illustrate the usage of **Session State** and **Callbacks** as we build a stateful Counter app. -For details on the Session State and Callbacks API, please refer to our [Session State API Reference Guide](/library/api-reference/session-state). +For details on the Session State and Callbacks API, please refer to our [Session State API Reference Guide](/develop/api-reference/caching-and-state/st.session_state). Also, check out this Session State basics tutorial video by Streamlit Developer Advocate Dr. Marisa Smith to get started: @@ -129,7 +129,7 @@ As you can see in the above example, pressing the **_Increment_** button updates Now that we've built a basic Counter app using Session State, let's move on to something a little more complex. The next example uses Callbacks with Session State. -**Callbacks**: A callback is a Python function which gets called when an input widget changes. Callbacks can be used with widgets using the parameters `on_change` (or `on_click`), `args`, and `kwargs`. The full Callbacks API can be found in our [Session State API Reference Guide](/library/api-reference/session-state#use-callbacks-to-update-session-state). +**Callbacks**: A callback is a Python function which gets called when an input widget changes. Callbacks can be used with widgets using the parameters `on_change` (or `on_click`), `args`, and `kwargs`. The full Callbacks API can be found in our [Session State API Reference Guide](/develop/api-reference/caching-and-state/st.session_state#use-callbacks-to-update-session-state). ```python import streamlit as st @@ -272,11 +272,11 @@ st.button('Submit', key='my_button') ### 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](https://docs.python.org/3/library/pickle.html) module serializes Python objects to a byte stream ("pickling") and deserializes the stream into an object ("unpickling"). +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](https://docs.python.org/3/develop/pickle.html) module serializes Python objects to a byte stream ("pickling") and deserializes the stream into an object ("unpickling"). -By default, Streamlit’s [Session State](/library/advanced-features/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](https://docs.python.org/3/reference/expressions.html#lambda) 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. +By default, Streamlit’s [Session State](/develop/concepts/architecture/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](https://docs.python.org/3/reference/expressions.html#lambda) 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](/library/advanced-features/configuration) 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: +To that end, Streamlit provides a `runner.enforceSerializableSessionState` [configuration option](/develop/concepts/configuration) 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: ```toml # .streamlit/config.toml @@ -284,7 +284,7 @@ To that end, Streamlit provides a `runner.enforceSerializableSessionState` [conf enforceSerializableSessionState = true ``` -By "_pickle-serializable_", we mean calling `pickle.dumps(obj)` should not raise a [`PicklingError`](https://docs.python.org/3/library/pickle.html#pickle.PicklingError) exception. When the config option is enabled, adding unserializable data to session state should result in an exception. E.g., +By "_pickle-serializable_", we mean calling `pickle.dumps(obj)` should not raise a [`PicklingError`](https://docs.python.org/3/develop/pickle.html#pickle.PicklingError) exception. When the config option is enabled, adding unserializable data to session state should result in an exception. E.g., ```python import streamlit as st @@ -310,4 +310,4 @@ Here are some limitations to keep in mind when using Session State: - Session State exists for as long as the tab is open and connected to the Streamlit server. As soon as you close the tab, everything stored in Session State is lost. - Session State is not persisted. If the Streamlit server crashes, then everything stored in Session State gets wiped -- For caveats and limitations with the Session State API, please see the [API limitations](/library/api-reference/session-state#caveats-and-limitations). +- For caveats and limitations with the Session State API, please see the [API limitations](/develop/api-reference/caching-and-state/st.session_state#caveats-and-limitations). diff --git a/content/library/advanced-features/st.cache.md b/content/library/advanced-features/st.cache.md index d90b33748..ed05b9b24 100644 --- a/content/library/advanced-features/st.cache.md +++ b/content/library/advanced-features/st.cache.md @@ -1,19 +1,19 @@ --- title: Optimize performance with st.cache -slug: /library/advanced-features/st.cache +slug: /develop/concepts/architecture/st.cache --- -`st.cache` was deprecated in version 1.18.0. Use [`st.cache_data`](/library/api-reference/performance/st.cache_data) or [`st.cache_resource`](/library/api-reference/performance/st.cache_resource) instead. Learn more in [Caching](/library/advanced-features/caching). +`st.cache` was deprecated in version 1.18.0. Use [`st.cache_data`](/develop/api-reference/caching-and-state/st.cache_data) or [`st.cache_resource`](/develop/api-reference/caching-and-state/st.cache_resource) instead. Learn more in [Caching](/develop/concepts/architecture/caching). # Optimize performance with st.cache -Streamlit provides a caching mechanism that allows your app to stay performant even when loading data from the web, manipulating large datasets, or performing expensive computations. This is done with the [`@st.cache`](/library/api-reference/performance/st.cache) decorator. +Streamlit provides a caching mechanism that allows your app to stay performant even when loading data from the web, manipulating large datasets, or performing expensive computations. This is done with the [`@st.cache`](/develop/api-reference/caching-and-state/st.cache) decorator. -When you mark a function with the [`@st.cache`](/library/api-reference/performance/st.cache) decorator, it tells Streamlit that whenever the function is called it needs to check a few things: +When you mark a function with the [`@st.cache`](/develop/api-reference/caching-and-state/st.cache) decorator, it tells Streamlit that whenever the function is called it needs to check a few things: 1. The input parameters that you called the function with 2. The value of any external variable used in the function @@ -24,7 +24,7 @@ If this is the first time Streamlit has seen these four components with these ex The way Streamlit keeps track of changes in these components is through hashing. Think of the cache as an in-memory key-value store, where the key is a hash of all of the above and the value is the actual output object passed by reference. -Finally, [`@st.cache`](/library/api-reference/performance/st.cache) supports arguments to configure the cache's behavior. You can find more information on those in our [API reference](/library/api-reference). +Finally, [`@st.cache`](/develop/api-reference/caching-and-state/st.cache) supports arguments to configure the cache's behavior. You can find more information on those in our [API reference](/develop/api-reference). Let's take a look at a few examples that illustrate how caching works in a Streamlit app. @@ -49,7 +49,7 @@ st.write("Result:", res) Try pressing **R** to rerun the app, and notice how long it takes for the result to show up. This is because `expensive_computation(a, b)` is being re-executed every time the app runs. This isn't a great experience. -Let's add the [`@st.cache`](/library/api-reference/performance/st.cache) decorator: +Let's add the [`@st.cache`](/develop/api-reference/caching-and-state/st.cache) decorator: ```python import streamlit as st @@ -202,7 +202,7 @@ res = expensive_computation(a, b) st.write("Result:", res) ``` -Even though `inner_func()` is not annotated with [`@st.cache`](/library/api-reference/performance/st.cache), when we edit its body we cause a "Cache miss" in the outer `expensive_computation()`. +Even though `inner_func()` is not annotated with [`@st.cache`](/develop/api-reference/caching-and-state/st.cache), when we edit its body we cause a "Cache miss" in the outer `expensive_computation()`. That's because Streamlit always traverses your code and its dependencies to verify that the cached values are still valid. This means that while developing your app you can edit your code freely without worrying about the cache. Any change you make to your app, Streamlit should do the right thing! @@ -234,7 +234,7 @@ What you'll see: - If you move the slider to a number Streamlit hasn't seen before, you'll have a cache miss again. And every subsequent rerun with the same number will be a cache hit, of course. - If you move the slider back to a number Streamlit has seen before, the cache is hit and the app is fast as expected. -In computer science terms, what is happening here is that [`@st.cache`](/library/api-reference/performance/st.cache) is [memoizing](https://en.wikipedia.org/wiki/Memoization) `expensive_computation(a, b)`. +In computer science terms, what is happening here is that [`@st.cache`](/develop/api-reference/caching-and-state/st.cache) is [memoizing](https://en.wikipedia.org/wiki/Memoization) `expensive_computation(a, b)`. But now let's go one step further! Try the following: @@ -299,7 +299,7 @@ In this specific case, the fix is just to not mutate `res["output"]` outside the ## Advanced caching -In [caching](/library/advanced-features/caching), you learned about the Streamlit cache, which is accessed with the [`@st.cache`](/library/api-reference/performance/st.cache) decorator. In this article you'll see how Streamlit's caching functionality is implemented, so that you can use it to improve the performance of your Streamlit apps. +In [caching](/develop/concepts/architecture/caching), you learned about the Streamlit cache, which is accessed with the [`@st.cache`](/develop/api-reference/caching-and-state/st.cache) decorator. In this article you'll see how Streamlit's caching functionality is implemented, so that you can use it to improve the performance of your Streamlit apps. The cache is a key-value store, where the key is a hash of: @@ -315,7 +315,7 @@ And the value is a tuple of: For both the key and the output hash, Streamlit uses a specialized hash function that knows how to traverse code, hash special objects, and can have its [behavior customized by the user](#the-hash_funcs-parameter). -For example, when the function `expensive_computation(a, b)`, decorated with [`@st.cache`](/library/api-reference/performance/st.cache), is executed with `a=2` and `b=21`, Streamlit does the following: +For example, when the function `expensive_computation(a, b)`, decorated with [`@st.cache`](/develop/api-reference/caching-and-state/st.cache), is executed with `a=2` and `b=21`, Streamlit does the following: 1. Computes the cache key 1. If the key is found in the cache, then: @@ -349,7 +349,7 @@ def func(file_reference): By default, Streamlit hashes custom classes like `FileReference` by recursively navigating their structure. In this case, its hash is the hash of the filename property. As long as the file name doesn't change, the hash will remain constant. -However, what if you wanted to have the hasher check for changes to the file's modification time, not just its name? This is possible with [`@st.cache`](/library/api-reference/performance/st.cache)'s `hash_funcs` parameter: +However, what if you wanted to have the hasher check for changes to the file's modification time, not just its name? This is possible with [`@st.cache`](/develop/api-reference/caching-and-state/st.cache)'s `hash_funcs` parameter: ```python class FileReference: @@ -391,7 +391,7 @@ Because Streamlit's hash function works recursively, you don't have to hash the While it's possible to write custom hash functions, let's take a look at some of the tools that Python provides out of the box. Here's a list of some hash functions and when it makes sense to use them. -Python's [`id`](https://docs.python.org/3/library/functions.html#id) function | [Example](#example-1-pass-a-database-connection-around) +Python's [`id`](https://docs.python.org/3/develop/functions.html#id) function | [Example](#example-1-pass-a-database-connection-around) - Speed: Fast - Use case: If you're hashing a singleton object, like an open database connection or a TensorFlow session. These are objects that will only be instantiated once, no matter how many times your script reruns. @@ -401,7 +401,7 @@ Python's [`id`](https://docs.python.org/3/library/functions.html#id) function | - Speed: Fast - Use case: If you want to turn off hashing of this type. This is useful if you know the object is not going to change. -Python's [`hash()`](https://docs.python.org/3/library/functions.html#hash) function | [Example](#example-3-use-pythons-hash-function) +Python's [`hash()`](https://docs.python.org/3/develop/functions.html#hash) function | [Example](#example-3-use-pythons-hash-function) - Speed: Can be slow based the size of the object being cached - Use case: If Python already knows how to hash this type correctly. diff --git a/content/library/advanced-features/static-file-serving.md b/content/library/advanced-features/static-file-serving.md index a7e47fab1..fc4bc490e 100644 --- a/content/library/advanced-features/static-file-serving.md +++ b/content/library/advanced-features/static-file-serving.md @@ -1,12 +1,12 @@ --- title: Static file serving -slug: /library/advanced-features/static-file-serving +slug: /develop/concepts/configuration/static-file-serving --- # Static file serving Streamlit apps can host and serve small, static media files to support media embedding use cases that -won't work with the normal [media elements](https://docs.streamlit.io/library/api-reference/media). +won't work with the normal [media elements](https://docs.streamlit.io/develop/api-reference/media). To enable this feature, set `enableStaticServing = true` under `[server]` in your config file, or environment variable `STREAMLIT_SERVER_ENABLE_STATIC_SERVING=true`. @@ -51,7 +51,7 @@ with st.echo(): Additional resources: -- [https://docs.streamlit.io/library/advanced-features/configuration](https://docs.streamlit.io/library/advanced-features/configuration) +- [https://docs.streamlit.io/develop/concepts/configuration](https://docs.streamlit.io/develop/concepts/configuration) - [https://static-file-serving.streamlit.app/](https://static-file-serving.streamlit.app/) diff --git a/content/library/advanced-features/theming.md b/content/library/advanced-features/theming.md index 04df29a85..309884ce0 100644 --- a/content/library/advanced-features/theming.md +++ b/content/library/advanced-features/theming.md @@ -1,6 +1,6 @@ --- title: Theming -slug: /library/advanced-features/theming +slug: /develop/concepts/configuration/theming --- # Theming @@ -14,7 +14,7 @@ Streamlit themes are defined using regular config options: a theme can be set via command line flag when starting your app using `streamlit run` or by defining it in the `[theme]` section of a `.streamlit/config.toml` file. For more information on setting config options, please refer to the -[Streamlit configuration documentation](/library/advanced-features/configuration#set-configuration-options). +[Streamlit configuration documentation](/develop/concepts/configuration#set-configuration-options). The following config options show the default Streamlit Light theme recreated in the `[theme]` section of a `.streamlit/config.toml` file. diff --git a/content/library/advanced-features/timezone-handling.md b/content/library/advanced-features/timezone-handling.md index 5ac5f777a..5f5b72e46 100644 --- a/content/library/advanced-features/timezone-handling.md +++ b/content/library/advanced-features/timezone-handling.md @@ -1,6 +1,6 @@ --- title: Working with timezones -slug: /library/advanced-features/timezone-handling +slug: /develop/concepts/design/timezone-handling --- # Working with timezones @@ -13,7 +13,7 @@ Streamlit always shows `datetime` information on the frontend with the same info ### **`datetime` instance without a timezone (naive)** -When you provide a `datetime` instance _without specifying a timezone_, the frontend shows the `datetime` instance without timezone information. For example (this also applies to other widgets like [`st.dataframe`](/library/api-reference/data/st.dataframe)): +When you provide a `datetime` instance _without specifying a timezone_, the frontend shows the `datetime` instance without timezone information. For example (this also applies to other widgets like [`st.dataframe`](/develop/api-reference/data/st.dataframe)): ```python import streamlit as st @@ -27,7 +27,7 @@ Users of the above app always see the output as `2020-01-10 10:30:00`. ### **`datetime` instance with a timezone** -When you provide a `datetime` instance _and specify a timezone_, the frontend shows the `datetime` instance in that same timezone. For example (this also applies to other widgets like [`st.dataframe`](/library/api-reference/data/st.dataframe)): +When you provide a `datetime` instance _and specify a timezone_, the frontend shows the `datetime` instance in that same timezone. For example (this also applies to other widgets like [`st.dataframe`](/develop/api-reference/data/st.dataframe)): ```python import streamlit as st @@ -44,6 +44,6 @@ In both cases, neither the date nor time information automatically adjusts to th -The legacy version of the `st.dataframe` has issues with timezones. We do not plan to roll out additional fixes or enhancements for the legacy dataframe. If you need stable timezone support, please consider switching to the arrow serialization by changing the [config setting](/library/advanced-features/configuration#set-configuration-options), _config.dataFrameSerialization = "arrow"_. +The legacy version of the `st.dataframe` has issues with timezones. We do not plan to roll out additional fixes or enhancements for the legacy dataframe. If you need stable timezone support, please consider switching to the arrow serialization by changing the [config setting](/develop/concepts/configuration#set-configuration-options), _config.dataFrameSerialization = "arrow"_. diff --git a/content/library/api-cheat-sheet.md b/content/library/api-cheat-sheet.md index fd8319ec5..4724ca9be 100644 --- a/content/library/api-cheat-sheet.md +++ b/content/library/api-cheat-sheet.md @@ -1,9 +1,9 @@ --- -title: Cheat sheet -slug: /library/cheatsheet +title: Streamlit API cheat sheet +slug: /develop/quick-reference/cheat-sheet --- -# Cheat Sheet +# Streamlit API cheat sheet This is a summary of the docs, as of [Streamlit v1.31.0](https://pypi.org/project/streamlit/1.31.0/). @@ -292,7 +292,7 @@ st.color_picker("Pick a color") >>> st.chat_input("Say something") ``` -Learn how to [Build a basic LLM chat app](/knowledge-base/tutorials/build-conversational-apps) +Learn how to [Build a basic LLM chat app](/develop/tutorials/llms/build-conversational-apps) diff --git a/content/library/api/api-reference.md b/content/library/api/_index.md similarity index 82% rename from content/library/api/api-reference.md rename to content/library/api/_index.md index 529fb0642..9c598ed49 100644 --- a/content/library/api/api-reference.md +++ b/content/library/api/_index.md @@ -1,8 +1,6 @@ --- title: API Reference -slug: /library/api-reference -next: caching -previous: index.md +slug: /develop/api-reference --- # API reference @@ -16,8 +14,13 @@ Browse our API below and click to learn more about any of our available commands ## Display almost anything +### Write and magic + +
    + - + +

    st.write

    @@ -30,7 +33,7 @@ st.write(my_mpl_figure) ```
    - +

    st.write_stream

    @@ -42,7 +45,7 @@ st.write_stream(my_llm_stream) ```
    - +

    Magic

    @@ -57,10 +60,12 @@ my_mpl_figure
    -## Text elements +### Text elements + +
    - + screenshot @@ -73,7 +78,7 @@ st.markdown("Hello **world**!") ``` - + screenshot @@ -86,7 +91,7 @@ st.title("The app title") ``` - + screenshot @@ -99,7 +104,7 @@ st.header("This is a header") ``` - + screenshot @@ -112,7 +117,7 @@ st.subheader("This is a subheader") ``` - + screenshot @@ -125,7 +130,7 @@ st.caption("This is written small caption text") ``` - + screenshot @@ -138,20 +143,21 @@ st.code("a = 1234") ``` - + -screenshot +screenshot -

    Preformatted text

    +

    Echo

    -Write fixed-width and preformatted text. +Display some code in the app, then execute it. Useful for tutorials. ```python -st.text("Hello world") +with st.echo(): + st.write('This code will be printed') ```
    - + screenshot @@ -164,7 +170,20 @@ st.latex("\int a x^2 \,dx") ``` - + + +screenshot + +

    Preformatted text

    + +Write fixed-width and preformatted text. + +```python +st.text("Hello world") +``` + +
    + screenshot @@ -251,10 +270,12 @@ mention(label="An awesome Streamlit App", icon="streamlit", url="https://extras -## Data elements +### Data elements + +
    - + screenshot

    Dataframes

    @@ -266,7 +287,7 @@ st.dataframe(my_data_frame) ```
    - + screenshot @@ -279,7 +300,7 @@ edited = st.data_editor(df, num_rows="dynamic") ``` - + screenshot @@ -293,7 +314,7 @@ st.column_config.NumberColumn("Price (in USD)", min_value=0, format="$%d") - + screenshot

    Static tables

    @@ -305,7 +326,7 @@ st.table(my_data_frame) ```
    - + screenshot

    Metrics

    @@ -317,7 +338,7 @@ st.metric("My metric", 42, 2) ```
    - + screenshot

    Dicts and JSON

    @@ -437,11 +458,13 @@ style_metric_cards() -## Chart elements +### Chart elements + +
    - + screenshot

    Simple area charts

    @@ -453,7 +476,7 @@ st.area_chart(my_data_frame) ```
    - + screenshot

    Simple bar charts

    @@ -465,7 +488,7 @@ st.bar_chart(my_data_frame) ```
    - + screenshot

    Simple line charts

    @@ -477,7 +500,7 @@ st.line_chart(my_data_frame) ```
    - + screenshot

    Simple scatter charts

    @@ -489,7 +512,7 @@ st.scatter_chart(my_data_frame) ```
    - + screenshot

    Scatterplots on maps

    @@ -501,7 +524,7 @@ st.map(my_data_frame) ```
    - + screenshot

    Matplotlib

    @@ -513,7 +536,7 @@ st.pyplot(my_mpl_figure) ```
    - + screenshot

    Altair

    @@ -525,7 +548,7 @@ st.altair_chart(my_altair_chart) ```
    - + screenshot

    Vega-Lite

    @@ -537,7 +560,7 @@ st.vega_lite_chart(my_vega_lite_chart) ```
    - + screenshot

    Plotly

    @@ -549,7 +572,7 @@ st.plotly_chart(my_plotly_chart) ```
    - + screenshot

    Bokeh

    @@ -561,7 +584,7 @@ st.bokeh_chart(my_bokeh_chart) ```
    - + screenshot

    PyDeck

    @@ -573,7 +596,7 @@ st.pydeck_chart(my_pydeck_chart) ```
    - + screenshot

    GraphViz

    @@ -726,10 +749,12 @@ st.altair_chart(chart, use_container_width=True) -## Input widgets +### Input widgets + +
    - + screenshot @@ -742,33 +767,33 @@ clicked = st.button("Click me") ``` - + -screenshot +screenshot -

    Data editor

    +

    Download button

    -Display a data editor widget. +Display a download button widget. ```python -edited = st.experimental_data_editor(df, num_rows="dynamic") +st.download_button("Download file", file) ```
    - + -screenshot +screenshot -

    Download button

    +

    Form button

    -Display a download button widget. +Display a form submit button. For use with `st.form`. ```python -st.download_button("Download file", file) +st.form_submit_button("Sign up") ```
    - + screenshot @@ -781,7 +806,7 @@ st.link_button("Go to gallery", url) ``` - + screenshot @@ -795,7 +820,7 @@ st.page_link("pages/profile.py", label="My profile") ``` - + screenshot @@ -808,20 +833,33 @@ selected = st.checkbox("I agree") ``` - + -screenshot +screenshot -

    Toggle

    +

    Color picker

    -Display a toggle widget. +Display a color picker widget. ```python -activated = st.toggle("Activate") +color = st.color_picker("Pick a color") ```
    - + + +screenshot + +

    Multiselect

    + +Display a multiselect widget. The multiselect widget starts as empty. + +```python +choices = st.multiselect("Buy", ["milk", "apples", "potatoes"]) +``` + +
    + screenshot @@ -834,7 +872,7 @@ choice = st.radio("Pick one", ["cats", "dogs"]) ``` - + screenshot @@ -847,20 +885,46 @@ choice = st.selectbox("Pick one", ["cats", "dogs"]) ``` - + -screenshot +screenshot -

    Multiselect

    +

    Select-slider

    -Display a multiselect widget. The multiselect widget starts as empty. +Display a slider widget to select items from a list. ```python -choices = st.multiselect("Buy", ["milk", "apples", "potatoes"]) +size = st.select_slider("Pick a size", ["S", "M", "L"]) ```
    - + + +screenshot + +

    Toggle

    + +Display a toggle widget. + +```python +activated = st.toggle("Activate") +``` + +
    + + +screenshot + +

    Number input

    + +Display a numeric input widget. + +```python +choice = st.number_input("Pick a number", 0, 10) +``` + +
    + screenshot @@ -873,46 +937,48 @@ number = st.slider("Pick a number", 0, 100) ``` - + -screenshot +screenshot -

    Select-slider

    +

    Date input

    -Display a slider widget to select items from a list. +Display a date input widget. ```python -size = st.select_slider("Pick a size", ["S", "M", "L"]) +date = st.date_input("Your birthday") ```
    - + -screenshot +screenshot -

    Text input

    +

    Time input

    -Display a single-line text input widget. +Display a time input widget. ```python -name = st.text_input("First name") +time = st.time_input("Meeting time") ```
    - + -screenshot +screenshot -

    Number input

    +

    Chat input

    -Display a numeric input widget. +Display a chat input widget. ```python -choice = st.number_input("Pick a number", 0, 10) +prompt = st.chat_input("Say something") +if prompt: + st.write(f"The user has sent: {prompt}") ```
    - + screenshot @@ -925,33 +991,33 @@ text = st.text_area("Text to translate") ``` - + -screenshot +screenshot -

    Date input

    +

    Text input

    -Display a date input widget. +Display a single-line text input widget. ```python -date = st.date_input("Your birthday") +name = st.text_input("First name") ```
    - + -screenshot +screenshot -

    Time input

    +

    Data editor

    -Display a time input widget. +Display a data editor widget. ```python -time = st.time_input("Meeting time") +edited = st.experimental_data_editor(df, num_rows="dynamic") ```
    - + screenshot @@ -964,7 +1030,7 @@ data = st.file_uploader("Upload a CSV") ``` - + screenshot @@ -976,19 +1042,6 @@ Display a widget that allows users to upload images directly from a camera. image = st.camera_input("Take a picture") ``` - - - -screenshot - -

    Color picker

    - -Display a color picker widget. - -```python -color = st.color_picker("Pick a color") -``` -
    @@ -1149,10 +1202,12 @@ stoggle( -## Media elements +### Media elements + +
    - + screenshot @@ -1168,7 +1223,7 @@ st.image("https://example.com/myimage.jpg") ``` - + screenshot @@ -1184,7 +1239,7 @@ st.audio("https://example.com/myaudio.mp3", format="audio/mp3") ``` - + screenshot @@ -1302,10 +1357,12 @@ st_lottie(lottie_hello, key="hello") -## Layouts and containers +### Layouts and containers + +
    - + screenshot @@ -1320,7 +1377,7 @@ col2.write("this is column 2") ``` - + screenshot @@ -1336,7 +1393,7 @@ c.write("This will show second") ``` - + screenshot @@ -1352,7 +1409,7 @@ c.write("This will show first") ``` - + screenshot @@ -1366,7 +1423,7 @@ with st.expander("Open to see more"): ``` - + screenshot @@ -1380,7 +1437,7 @@ with st.popover("Settings"): ``` - + screenshot @@ -1394,7 +1451,7 @@ st.sidebar.button("Click me!") ``` - + screenshot @@ -1466,14 +1523,16 @@ show_pages([ Page("streamlit_app.py", "Home", "🏠"), -## Chat elements +### Chat elements + +
    Streamlit provides a few commands to help you build conversational apps. These chat elements are designed to be used in conjunction with each other, but you can also use them separately. `st.chat_message` lets you insert a chat message container into the app so you can display messages from the user or the app. Chat containers can contain other Streamlit elements, including charts, tables, text, and more. `st.chat_input` lets you display a chat input widget so the user can type in a message. - + screenshot @@ -1488,7 +1547,7 @@ if prompt: ``` - + screenshot @@ -1504,7 +1563,7 @@ with st.chat_message("user"): ``` - + screenshot @@ -1518,7 +1577,7 @@ with st.status('Running'): ``` - +

    st.write_stream

    @@ -1532,10 +1591,12 @@ st.write_stream(my_llm_stream)
    -## Display progress and status +### Status elements + +
    - + screenshot @@ -1550,7 +1611,7 @@ for i in range(101): ``` - + screenshot @@ -1564,7 +1625,7 @@ with st.spinner("Please wait..."): ``` - + screenshot @@ -1578,7 +1639,7 @@ with st.status('Running'): ``` - + screenshot @@ -1591,7 +1652,7 @@ st.toast('Butter!', icon='🧈') ``` - + screenshot @@ -1607,7 +1668,7 @@ st.balloons() ``` - + screenshot @@ -1623,59 +1684,59 @@ st.snow() ``` - + -screenshot +screenshot -

    Error box

    +

    Success box

    -Display error message. +Display a success message. ```python -st.error("We encountered an error") +st.success("Match found!") ```
    - + -screenshot +screenshot -

    Warning box

    +

    Info box

    -Display warning message. +Display an informational message. ```python -st.warning("Unable to fetch image. Skipping...") +st.info("Dataset is updated every day at midnight.") ```
    - + -screenshot +screenshot -

    Info box

    +

    Warning box

    -Display an informational message. +Display warning message. ```python -st.info("Dataset is updated every day at midnight.") +st.warning("Unable to fetch image. Skipping...") ```
    - + -screenshot +screenshot -

    Success box

    +

    Error box

    -Display a success message. +Display error message. ```python -st.success("Match found!") +st.error("We encountered an error") ```
    - + screenshot @@ -1747,10 +1808,49 @@ rain(emoji="🎈", font_size=54, -## Control flow +## App logic and configuration + +### Navigation and pages + +
    - + + + +

    Switch page

    + +Programmatically navigates to a specified page. + +```python +st.switch_page("pages/my_page.py") +``` + +
    + + + +screenshot + +

    Page link

    + +Display a link to another page in a multipage app. + +```python +st.page_link("app.py", label="Home", icon="🏠") +st.page_link("pages/profile.py", label="My profile") +``` + +
    + +
    + +### Execution flow + +
    + + +

    Forms

    @@ -1764,7 +1864,7 @@ with st.form(key='my_form'): ```
    - +

    Rerun script

    @@ -1775,7 +1875,7 @@ st.rerun() ```
    - +

    Stop execution

    @@ -1785,17 +1885,6 @@ Stops execution immediately. st.stop() ``` -
    - - -

    Switch page

    - -Programmatically navigates to a specified page. - -```python -st.switch_page("pages/my_page.py") -``` -
    @@ -1854,152 +1943,176 @@ show_pages([ Page("streamlit_app.py", "Home", "🏠"), -## Developer tools +### Caching and state - - - +
    -screenshot + + -

    Pandas Profiling

    +

    Cache data

    -Pandas profiling component for Streamlit. Created by [@okld](https://github.com/okld/). +Function decorator to cache functions that return data (e.g. dataframe transforms, database queries, ML inference). ```python -df = pd.read_csv("https://storage.googleapis.com/tf-datasets/titanic/train.csv") -pr = df.profile_report() - -st_profile_report(pr) +@st.cache_data +def long_function(param1, param2): + # Perform expensive computation here or + # fetch data from the web here + return data ``` -
    - - +
    -screenshot + -

    Streamlit Ace

    +

    Cache resource

    -Ace editor component for Streamlit. Created by [@okld](https://github.com/okld). +Function decorator to cache functions that return global resources (e.g. database connections, ML models). ```python -from streamlit_ace import st_ace - -content = st_ace() -content +@st.cache_resource +def init_model(): + # Return a global resource here + return pipeline( + "sentiment-analysis", + model="distilbert-base-uncased-finetuned-sst-2-english" + ) ``` - - - +
    -screenshot + -

    Streamlit Analytics

    +

    Session state

    -Track & visualize user interactions with your streamlit app. Created by [@jrieke](https://github.com/jrieke). +Session state is a way to share variables between reruns, for each user session. ```python -import streamlit_analytics +st.session_state['key'] = value +``` -with streamlit_analytics.track(): - st.text_input("Write something") +
    + + + +

    Query parameters

    + +Get, set, or clear the query parameters that are shown in the browser's URL bar. + +```python +st.query_params[key] = value +st.query_params.clear() ``` - +
    - +
    + +### Connections and databases -## Utilities +#### Setup your connection - + -

    Set page title, favicon, and more

    +screenshot -Configures the default settings of the page. +

    Create a connection

    + +Connect to a data source or API ```python -st.set_page_config( - page_title="My app", - page_icon=":shark:", -) +conn = st.connection('pets_db', type='sql') +pet_owners = conn.query('select * from pet_owners') +st.dataframe(pet_owners) ```
    - +
    -

    Echo

    +#### Built-in connections -Display some code on the app, then execute it. Useful for tutorials. + -```python -with st.echo(): - st.write('This code will be printed') -``` + - - +screenshot -

    Get help

    +

    SnowflakeConnection

    -Display object’s doc string, nicely formatted. +A connection to Snowflake. ```python -st.help(st.write) -st.help(pd.DataFrame) +conn = st.connection('snowflake') ```
    - -

    Query parameters

    + -Get, set, or clear the query parameters that are shown in the browser's URL bar. +screenshot + +

    SQLConnection

    + +A connection to a SQL database using SQLAlchemy. ```python -st.query_params[key] = value -st.query_params.clear() +conn = st.connection('sql') ```
    -## Mutate charts +#### Build your own connections - + -

    Add rows

    +

    Connection base class

    -Append a dataframe to the bottom of the current one in certain elements, for optimized data updates. +Build your own connection with `BaseConnection`. ```python -element = st.line_chart(df) -element.add_rows(df_with_extra_rows) +class MyConnection(BaseConnection[myconn.MyConnection]): + def _connect(self, **kwargs) -> MyConnection: + return myconn.connect(**self._secrets, **kwargs) + def query(self, query): + return self._instance.query(query) ```
    +
    -## State management +#### Secrets management - -

    Session state

    + -Session state is a way to share variables between reruns, for each user session. +

    Secrets singleton

    + +Access secrets from a local TOML file. ```python -st.session_state['key'] = value +key = st.secrets["OpenAI_key"] +``` + +
    + + +

    Secrets file

    + +Save your secrets in a per-project or per-profile TOML file. + +```python +OpenAI_key = "" ```
    -
    -## Connections and databases +
    @@ -2056,145 +2169,134 @@ st.write(user_info) -## Performance +### Custom Components + +
    - -

    Cache data

    + -Function decorator to cache functions that return data (e.g. dataframe transforms, database queries, ML inference). +

    Declare a component

    + +Create and register a custom component. ```python -@st.cache_data -def long_function(param1, param2): - # Perform expensive computation here or - # fetch data from the web here - return data +st.components.v1.declare_component( + "custom_slider", + "/frontend", +) ```
    - + -

    Cache resource

    +

    HTML

    -Function decorator to cache functions that return global resources (e.g. database connections, ML models). +Display an HTML string in an iframe. ```python -@st.cache_resource -def init_model(): - # Return a global resource here - return pipeline( - "sentiment-analysis", - model="distilbert-base-uncased-finetuned-sst-2-english" - ) +st.components.v1.html( + "

    Foo bar.

    " +) ```
    -
    - -## Connections and databases - -### Setup your connection - - - - -screenshot + -

    Create a connection

    +

    iframe

    -Connect to a data source or API +Load a remote URL in an iframe. ```python -conn = st.connection('pets_db', type='sql') -pet_owners = conn.query('select * from pet_owners') -st.dataframe(pet_owners) +st.components.v1.iframe( + "docs.streamlit.io" +) ```
    +
    -### Built-in connections +### Utilities and data - +
    - - -screenshot + + -

    SnowflakeConnection

    +

    User info

    -A connection to Snowflake. +`st.experimental_user` returns information about the logged-in user of private apps on Streamlit Community Cloud. ```python -conn = st.connection('snowflake') +if st.experimental_user.email == "foo@corp.com": + st.write("Welcome back, ", st.experimental_user.email) +else: + st.write("You are not authorized to view this page.") ```
    + - - -screenshot - -

    SQLConnection

    +

    Get help

    -A connection to a SQL database using SQLAlchemy. +Display object’s doc string, nicely formatted. ```python -conn = st.connection('sql') +st.help(st.write) +st.help(pd.DataFrame) ```
    -### Third-party connections +### Configuration + +
    - + -

    Connection base class

    +

    Configuration file

    -Build your own connection with `BaseConnection`. +Configures the default settings for your app. -```python -class MyConnection(BaseConnection[myconn.MyConnection]): - def _connect(self, **kwargs) -> MyConnection: - return myconn.connect(**self._secrets, **kwargs) - def query(self, query): - return self._instance.query(query) +``` +your-project/ +├── .streamlit/ +│ └── config.toml +└── your_app.py ```
    + -
    - -## Personalization - - - - -

    User info

    +

    Set page title, favicon, and more

    -`st.experimental_user` returns information about the logged-in user of private apps on Streamlit Community Cloud. +Configures the default settings of the page. ```python -if st.experimental_user.email == "foo@corp.com": - st.write("Welcome back, ", st.experimental_user.email) -else: - st.write("You are not authorized to view this page.") +st.set_page_config( + page_title="My app", + page_icon=":shark:", +) ```
    -## App testing +## Developer tools + +### App testing + +
    - +

    st.testing.v1.AppTest

    @@ -2214,7 +2316,7 @@ assert at.warning[0].value == "Try again."
    - +

    AppTest.from_file

    @@ -2229,7 +2331,7 @@ at.run()
    - +

    AppTest.from_string

    @@ -2244,7 +2346,7 @@ at.run()
    - +

    AppTest.from_function

    @@ -2259,7 +2361,7 @@ at.run()
    - +

    Block

    @@ -2279,7 +2381,7 @@ assert not at.exception
    - +

    Element

    @@ -2298,7 +2400,7 @@ assert at.title[0].value == "My awesome app"
    - +

    Button

    @@ -2310,7 +2412,7 @@ at.button[0].click().run()
    - +

    ChatInput

    @@ -2322,7 +2424,7 @@ at.chat_input[0].set_value("What is Streamlit?").run()
    - +

    Checkbox

    @@ -2334,7 +2436,7 @@ at.checkbox[0].check().run()
    - +

    ColorPicker

    @@ -2346,7 +2448,7 @@ at.color_picker[0].pick("#FF4B4B").run()
    - +

    DateInput

    @@ -2359,7 +2461,7 @@ at.date_input[0].set_value(release_date).run()
    - +

    Multiselect

    @@ -2371,7 +2473,7 @@ at.multiselect[0].select("New York").run()
    - +

    NumberInput

    @@ -2383,7 +2485,7 @@ at.number_input[0].increment().run()
    - +

    Radio

    @@ -2395,7 +2497,7 @@ at.radio[0].set_value("New York").run()
    - +

    SelectSlider

    @@ -2407,7 +2509,7 @@ at.select_slider[0].set_range("A","C").run()
    - +

    Selectbox

    @@ -2419,7 +2521,7 @@ at.selectbox[0].select("New York").run()
    - +

    Slider

    @@ -2431,7 +2533,7 @@ at.slider[0].set_range(2,5).run()
    - +

    TextArea

    @@ -2443,7 +2545,7 @@ at.text_area[0].input("Streamlit is awesome!").run()
    - +

    TextInput

    @@ -2455,7 +2557,7 @@ at.text_input[0].input("Streamlit").run()
    - +

    TimeInput

    @@ -2467,7 +2569,7 @@ at.time_input[0].increment().run()
    - +

    Toggle

    @@ -2480,3 +2582,58 @@ at.toggle[0].set_value("True").run()
    + + + + + +screenshot + +

    Pandas Profiling

    + +Pandas profiling component for Streamlit. Created by [@okld](https://github.com/okld/). + +```python +df = pd.read_csv("https://storage.googleapis.com/tf-datasets/titanic/train.csv") +pr = df.profile_report() + +st_profile_report(pr) +``` + +
    + + + +screenshot + +

    Streamlit Ace

    + +Ace editor component for Streamlit. Created by [@okld](https://github.com/okld). + +```python +from streamlit_ace import st_ace + +content = st_ace() +content +``` + +
    + + + +screenshot + +

    Streamlit Analytics

    + +Track & visualize user interactions with your streamlit app. Created by [@jrieke](https://github.com/jrieke). + +```python +import streamlit_analytics + +with streamlit_analytics.track(): + st.text_input("Write something") +``` + +
    + +
    diff --git a/content/library/api/charts/charts.md b/content/library/api/charts/_index.md similarity index 88% rename from content/library/api/charts/charts.md rename to content/library/api/charts/_index.md index a7db9d3a7..a37d23f54 100644 --- a/content/library/api/charts/charts.md +++ b/content/library/api/charts/_index.md @@ -1,6 +1,6 @@ --- title: Chart elements -slug: /library/api-reference/charts +slug: /develop/api-reference/charts --- # Chart elements @@ -14,8 +14,10 @@ Lite](https://vega.github.io/vega-lite/) (2D charts) and finally we also provide a few chart types that are "native" to Streamlit, like `st.line_chart` and `st.area_chart`. +## Simple chart elements + - + screenshot

    Simple area charts

    @@ -27,7 +29,7 @@ st.area_chart(my_data_frame) ```
    - + screenshot

    Simple bar charts

    @@ -39,7 +41,7 @@ st.bar_chart(my_data_frame) ```
    - + screenshot

    Simple line charts

    @@ -51,7 +53,7 @@ st.line_chart(my_data_frame) ```
    - + screenshot

    Simple scatter charts

    @@ -63,7 +65,7 @@ st.scatter_chart(my_data_frame) ```
    - + screenshot

    Scatterplots on maps

    @@ -75,7 +77,12 @@ st.map(my_data_frame) ```
    - +
    + +## Advanced chart elements + + + screenshot

    Matplotlib

    @@ -87,7 +94,7 @@ st.pyplot(my_mpl_figure) ```
    - + screenshot

    Altair

    @@ -99,7 +106,7 @@ st.altair_chart(my_altair_chart) ```
    - + screenshot

    Vega-Lite

    @@ -111,7 +118,7 @@ st.vega_lite_chart(my_vega_lite_chart) ```
    - + screenshot

    Plotly

    @@ -123,7 +130,7 @@ st.plotly_chart(my_plotly_chart) ```
    - + screenshot

    Bokeh

    @@ -135,7 +142,7 @@ st.bokeh_chart(my_bokeh_chart) ```
    - + screenshot

    PyDeck

    @@ -147,7 +154,7 @@ st.pydeck_chart(my_pydeck_chart) ```
    - + screenshot

    GraphViz

    diff --git a/content/library/api/charts/altair_chart.md b/content/library/api/charts/altair_chart.md index 8a3c283e3..5f75f0043 100644 --- a/content/library/api/charts/altair_chart.md +++ b/content/library/api/charts/altair_chart.md @@ -1,11 +1,13 @@ --- title: st.altair_chart -slug: /library/api-reference/charts/st.altair_chart +slug: /develop/api-reference/charts/st.altair_chart description: st.altair_chart displays a chart using the Altair library. --- + + ### Theming Altair charts are displayed using the Streamlit theme by default. This theme is sleek, user-friendly, and incorporates Streamlit's color palette. The added benefit is that your charts better integrate with the rest of your app's design. @@ -149,7 +151,7 @@ source = get_data() Next, we define a function `get_chart()` to create the interactive time-series chart of the stock prices with a multi-line tooltip. The x-axis represents the date, and the y-axis represents the stock price. -We then invoke `get_chart()` that takes the stock prices dataframe as an input and returns a chart object. This is going to be our base chart on which we will overlay the annotations in [Step 2](/library/api-reference/charts/st.altair_chart#step-2-annotate-the-chart). +We then invoke `get_chart()` that takes the stock prices dataframe as an input and returns a chart object. This is going to be our base chart on which we will overlay the annotations in [Step 2](/develop/api-reference/charts/st.altair_chart#step-2-annotate-the-chart). ```python # Define the base time-series chart. @@ -202,7 +204,7 @@ For simplicity, let's annotate four specific dates and set the height of the ann -You can vary the horizontal and vertical postions of the annotations by replacing the hard-coded values with the output of Streamlit widgets! Click [here](/library/api-reference/charts/st.altair_chart#interactive-example) to jump to a live example below, and develop an intuition for the ideal horizontal and vertical positions of the annotations by playing with Streamlit widgets. +You can vary the horizontal and vertical postions of the annotations by replacing the hard-coded values with the output of Streamlit widgets! Click [here](/develop/api-reference/charts/st.altair_chart#interactive-example) to jump to a live example below, and develop an intuition for the ideal horizontal and vertical positions of the annotations by playing with Streamlit widgets. diff --git a/content/library/api/charts/area_chart.md b/content/library/api/charts/area_chart.md index ac834cd70..50bbbf71c 100644 --- a/content/library/api/charts/area_chart.md +++ b/content/library/api/charts/area_chart.md @@ -1,7 +1,9 @@ --- title: st.area_chart -slug: /library/api-reference/charts/st.area_chart +slug: /develop/api-reference/charts/st.area_chart description: st.area_chart displays an area chart. --- + + diff --git a/content/library/api/charts/bar_chart.md b/content/library/api/charts/bar_chart.md index 20b8899a4..7500ecc26 100644 --- a/content/library/api/charts/bar_chart.md +++ b/content/library/api/charts/bar_chart.md @@ -1,7 +1,9 @@ --- title: st.bar_chart -slug: /library/api-reference/charts/st.bar_chart +slug: /develop/api-reference/charts/st.bar_chart description: st.bar_chart displays a bar chart. --- + + diff --git a/content/library/api/charts/bokeh_chart.md b/content/library/api/charts/bokeh_chart.md index 10a57efde..5fcecadd5 100644 --- a/content/library/api/charts/bokeh_chart.md +++ b/content/library/api/charts/bokeh_chart.md @@ -1,7 +1,9 @@ --- title: st.bokeh_chart -slug: /library/api-reference/charts/st.bokeh_chart +slug: /develop/api-reference/charts/st.bokeh_chart description: st.bokeh_chart displays an interactive Bokeh chart. --- + + diff --git a/content/library/api/charts/graphviz_chart.md b/content/library/api/charts/graphviz_chart.md index 9ca464f10..d651198da 100644 --- a/content/library/api/charts/graphviz_chart.md +++ b/content/library/api/charts/graphviz_chart.md @@ -1,7 +1,9 @@ --- title: st.graphviz_chart -slug: /library/api-reference/charts/st.graphviz_chart +slug: /develop/api-reference/charts/st.graphviz_chart description: st.graphviz_chart displays a graph using the dagre-d3 library. --- + + diff --git a/content/library/api/charts/line_chart.md b/content/library/api/charts/line_chart.md index 5023daa55..f0c8730b9 100644 --- a/content/library/api/charts/line_chart.md +++ b/content/library/api/charts/line_chart.md @@ -1,7 +1,9 @@ --- title: st.line_chart -slug: /library/api-reference/charts/st.line_chart +slug: /develop/api-reference/charts/st.line_chart description: st.line_chart displays a line chart. --- + + diff --git a/content/library/api/charts/map.md b/content/library/api/charts/map.md index 698801612..bcfde0b52 100644 --- a/content/library/api/charts/map.md +++ b/content/library/api/charts/map.md @@ -1,7 +1,9 @@ --- title: st.map -slug: /library/api-reference/charts/st.map +slug: /develop/api-reference/charts/st.map description: st.map displays a map with points on it. --- + + diff --git a/content/library/api/charts/plotly_chart.md b/content/library/api/charts/plotly_chart.md index 00772b003..d53baf36c 100644 --- a/content/library/api/charts/plotly_chart.md +++ b/content/library/api/charts/plotly_chart.md @@ -1,11 +1,13 @@ --- title: st.plotly_chart -slug: /library/api-reference/charts/st.plotly_chart +slug: /develop/api-reference/charts/st.plotly_chart description: st.plotly_chart displays an interactive Plotly chart. --- + + ### Theming Plotly charts are displayed using the Streamlit theme by default. This theme is sleek, user-friendly, and incorporates Streamlit's color palette. The added benefit is that your charts better integrate with the rest of your app's design. diff --git a/content/library/api/charts/pydeck_chart.md b/content/library/api/charts/pydeck_chart.md index 2131ab6b4..ba79e8847 100644 --- a/content/library/api/charts/pydeck_chart.md +++ b/content/library/api/charts/pydeck_chart.md @@ -1,7 +1,9 @@ --- title: st.pydeck_chart -slug: /library/api-reference/charts/st.pydeck_chart +slug: /develop/api-reference/charts/st.pydeck_chart description: st.pydeck_chart displays a chart using the PyDeck library. --- + + diff --git a/content/library/api/charts/pyplot.md b/content/library/api/charts/pyplot.md index ef81d2756..08b173084 100644 --- a/content/library/api/charts/pyplot.md +++ b/content/library/api/charts/pyplot.md @@ -1,7 +1,9 @@ --- title: st.pyplot -slug: /library/api-reference/charts/st.pyplot +slug: /develop/api-reference/charts/st.pyplot description: st.pyplot displays a matplotlib.pyplot figure. --- + + diff --git a/content/library/api/charts/scatter_chart.md b/content/library/api/charts/scatter_chart.md index 6b4dd1c9c..237a1061f 100644 --- a/content/library/api/charts/scatter_chart.md +++ b/content/library/api/charts/scatter_chart.md @@ -1,7 +1,9 @@ --- title: st.scatter_chart -slug: /library/api-reference/charts/st.scatter_chart +slug: /develop/api-reference/charts/st.scatter_chart description: st.scatter_chart displays an scatter chart. --- + + diff --git a/content/library/api/charts/vega_lite_chart.md b/content/library/api/charts/vega_lite_chart.md index aa008e341..6a82c6e3d 100644 --- a/content/library/api/charts/vega_lite_chart.md +++ b/content/library/api/charts/vega_lite_chart.md @@ -1,11 +1,13 @@ --- title: st.vega_lite_chart -slug: /library/api-reference/charts/st.vega_lite_chart +slug: /develop/api-reference/charts/st.vega_lite_chart description: st.vega_lite_chart displays a chart using the Vega-Lite library. --- + + ### Theming Vega-Lite charts are displayed using the Streamlit theme by default. This theme is sleek, user-friendly, and incorporates Streamlit's color palette. The added benefit is that your charts better integrate with the rest of your app's design. diff --git a/content/library/api/chat/chat.md b/content/library/api/chat/_index.md similarity index 85% rename from content/library/api/chat/chat.md rename to content/library/api/chat/_index.md index 38be9bc2b..cc28fba5d 100644 --- a/content/library/api/chat/chat.md +++ b/content/library/api/chat/_index.md @@ -1,6 +1,6 @@ --- title: Chat elements -slug: /library/api-reference/chat +slug: /develop/api-reference/chat --- # Chat elements @@ -10,7 +10,7 @@ Streamlit provides a few commands to help you build conversational apps. These c `st.chat_message` lets you insert a chat message container into the app so you can display messages from the user or the app. Chat containers can contain other Streamlit elements, including charts, tables, text, and more. `st.chat_input` lets you display a chat input widget so the user can type in a message. Remember to check out `st.status` to display output from long-running processes and external API calls. - + screenshot @@ -25,7 +25,7 @@ if prompt: ``` - + screenshot @@ -41,7 +41,7 @@ with st.chat_message("user"): ``` - + screenshot @@ -55,7 +55,7 @@ with st.status('Running'): ``` - +

    st.write_stream

    diff --git a/content/library/api/chat/chat-input.md b/content/library/api/chat/chat-input.md index 7eff53900..52ec3284e 100644 --- a/content/library/api/chat/chat-input.md +++ b/content/library/api/chat/chat-input.md @@ -1,12 +1,12 @@ --- title: st.chat_input -slug: /library/api-reference/chat/st.chat_input +slug: /develop/api-reference/chat/st.chat_input description: st.chat_input displays a chat input widget. --- -Read the [Build a basic LLM chat app](/knowledge-base/tutorials/build-conversational-apps) tutorial to learn how to use `st.chat_message` and `st.chat_input` to build chat-based apps. +Read the [Build a basic LLM chat app](/develop/tutorials/llms/build-conversational-apps) tutorial to learn how to use `st.chat_message` and `st.chat_input` to build chat-based apps. diff --git a/content/library/api/chat/chat-message.md b/content/library/api/chat/chat-message.md index 9d258d530..7bdc31589 100644 --- a/content/library/api/chat/chat-message.md +++ b/content/library/api/chat/chat-message.md @@ -1,12 +1,12 @@ --- title: st.chat_message -slug: /library/api-reference/chat/st.chat_message +slug: /develop/api-reference/chat/st.chat_message description: st.chat_message inserts a chat message container into the app. --- -Read the [Build a basic LLM chat app](/knowledge-base/tutorials/build-conversational-apps) tutorial to learn how to use `st.chat_message` and `st.chat_input` to build chat-based apps. +Read the [Build a basic LLM chat app](/develop/tutorials/llms/build-conversational-apps) tutorial to learn how to use `st.chat_message` and `st.chat_input` to build chat-based apps. diff --git a/content/library/advanced-features/cli.md b/content/library/api/command-line/_index.md similarity index 83% rename from content/library/advanced-features/cli.md rename to content/library/api/command-line/_index.md index 59b7030ee..aeab54042 100644 --- a/content/library/advanced-features/cli.md +++ b/content/library/api/command-line/_index.md @@ -1,6 +1,6 @@ --- title: Command-line options -slug: /library/advanced-features/cli +slug: /develop/api-reference/cli --- # Command-line interface @@ -55,12 +55,12 @@ Opens the Streamlit documentation (i.e. this website) in a web browser. streamlit cache clear ``` -Clears persisted files from the on-disk [Streamlit cache](/library/api-reference/performance), if +Clears persisted files from the on-disk [Streamlit cache](/develop/api-reference/caching-and-state), if present. ### View all configuration options -As described in [Configuration](/library/advanced-features/configuration), Streamlit has several +As described in [Configuration](/develop/concepts/configuration), Streamlit has several configuration options. To view them all, including their current values, just type: ```bash diff --git a/content/library/api/command-line/run.md b/content/library/api/command-line/run.md new file mode 100644 index 000000000..0bcb7cd57 --- /dev/null +++ b/content/library/api/command-line/run.md @@ -0,0 +1,74 @@ +--- +title: streamlit run +slug: /develop/api-reference/cli/run +--- + +## `$ streamlit run` + +### Syntax + +``` +streamlit run [-- config options] [script args] +``` + +### Arguments + +``: The path to your entrypoint file for your Streamlit app. Your entrypoint file is your app's homepage. + +### Options + +Configuration options are passed in the form of `--
    .
    -4. If you will be deploying or managing any apps, click "**Connect GitHub account**" and proceed to [Step 2: Source Control](/streamlit-community-cloud/get-started/create-your-account#step-2-source-control). If you are only going to be viewing apps and will not be using GitHub, you can click "**Skip this step**" and proceed to [Step 3: Set up your account](#step-3-set-up-your-account). +4. If you will be deploying or managing any apps, click "**Connect GitHub account**" and proceed to [Step 2: Source Control](/deploy/streamlit-community-cloud/get-started/create-your-account#step-2-source-control). If you are only going to be viewing apps and will not be using GitHub, you can click "**Skip this step**" and proceed to [Step 3: Set up your account](#step-3-set-up-your-account).
    Connect your GitHub account to Streamlit Community Cloud @@ -67,7 +67,7 @@ If you're sharing a private app, you will assign viewing permission by email. Th Streamlit Community Cloud sign-in email
    -5. If you will be deploying or managing any apps, click "**Connect GitHub account**" and proceed to [Step 2: Source control](/streamlit-community-cloud/get-started/create-your-account#step-2-source-control). If you are only going to be viewing apps and will not be using GitHub, you can click "**Skip this step**" and proceed to [Step 3: Set up your account](#step-3-set-up-your-account). +5. If you will be deploying or managing any apps, click "**Connect GitHub account**" and proceed to [Step 2: Source control](/deploy/streamlit-community-cloud/get-started/create-your-account#step-2-source-control). If you are only going to be viewing apps and will not be using GitHub, you can click "**Skip this step**" and proceed to [Step 3: Set up your account](#step-3-set-up-your-account).
    Connect your GitHub account to Streamlit Community Cloud @@ -77,7 +77,7 @@ If you're sharing a private app, you will assign viewing permission by email. Th Streamlit Community Cloud is integrated with GitHub for source control. If you begin your sign-up process with GitHub, you will not be directly prompted to create a primary identity. However, you can attach a Google account later. -There are two different authorization requests to completely [Connect your GitHub account](/streamlit-community-cloud/get-started/connect-your-github-account). You will encounter the first authorization request when you begin connecting your GitHub account. A second authorization is needed the first time you deploy an app. If you will be deploying or managing any apps from a GitHub organization, your authorization requests will include additional options to allow [Organization access](/streamlit-community-cloud/get-started/connect-github#organization-access). +There are two different authorization requests to completely [Connect your GitHub account](/deploy/streamlit-community-cloud/get-started/connect-your-github-account). You will encounter the first authorization request when you begin connecting your GitHub account. A second authorization is needed the first time you deploy an app. If you will be deploying or managing any apps from a GitHub organization, your authorization requests will include additional options to allow [Organization access](/deploy/streamlit-community-cloud/get-started/connect-github#organization-access). 1. After completing [Step 1: Primary identity](#step-1-primary-identity) or after clicking "**Continue with GitHub**" from the sign-up page, enter your GitHub credentials and click "**Sign in**". @@ -119,4 +119,4 @@ Congratulations on creating your Streamlit Community Cloud account! A warning ic ## What's next? -Now that you have your account you can [Explore your workspace](/streamlit-community-cloud/get-started/explore-your-workspace). Or if you're ready to go, jump right in and [Deploy your app](/streamlit-community-cloud/deploy-your-app). +Now that you have your account you can [Explore your workspace](/deploy/streamlit-community-cloud/get-started/explore-your-workspace). Or if you're ready to go, jump right in and [Deploy your app](/deploy/streamlit-community-cloud/deploy-your-app). diff --git a/content/streamlit-cloud/get-started/explore-your-workspace.md b/content/streamlit-cloud/get-started/explore-your-workspace.md index f60bdaa10..d3683e3e1 100644 --- a/content/streamlit-cloud/get-started/explore-your-workspace.md +++ b/content/streamlit-cloud/get-started/explore-your-workspace.md @@ -1,33 +1,33 @@ --- title: Explore your workspace -slug: /streamlit-community-cloud/get-started/explore-your-workspace +slug: /deploy/streamlit-community-cloud/get-started/explore-your-workspace --- # Explore your workspace -If you just [created your account](/streamlit-community-cloud/get-started/create-your-account), congrats! You are now logged in and ready to go. If you are joining someone else's workspace you may already see apps populated in your workspace. If not, then you need to deploy an app! Check out our next section on how to [Deploy your app](/streamlit-community-cloud/deploy-your-app). If you need an app to deploy, check out our App gallery which includes apps for machine learning, data science, and business use cases. +If you just [created your account](/deploy/streamlit-community-cloud/get-started/create-your-account), congrats! You are now logged in and ready to go. If you are joining someone else's workspace you may already see apps populated in your workspace. If not, then you need to deploy an app! Check out our next section on how to [Deploy your app](/deploy/streamlit-community-cloud/deploy-your-app). If you need an app to deploy, check out our App gallery which includes apps for machine learning, data science, and business use cases. ![Your Streamlit Community Cloud workspace](/images/streamlit-community-cloud/workspace-empty.png) ## Switching workspaces -You may also find that you already have access to multiple Streamlit Community Cloud workspaces. Streamlit Community Cloud automatically groups your apps according to the corresponding GitHub repository's owner or organzation. In the upper-right corner you can see the workspaces you have access to. If apps have already been deployed from any of your repositories, then you will see those apps when you select the associated workspace in the upper-right corner. Learn more about how to [Manage your app from your workspace](/streamlit-community-cloud/manage-your-app#manage-your-app-from-your-workspace). +You may also find that you already have access to multiple Streamlit Community Cloud workspaces. Streamlit Community Cloud automatically groups your apps according to the corresponding GitHub repository's owner or organzation. In the upper-right corner you can see the workspaces you have access to. If apps have already been deployed from any of your repositories, then you will see those apps when you select the associated workspace in the upper-right corner. Learn more about how to [Manage your app from your workspace](/deploy/streamlit-community-cloud/manage-your-app#manage-your-app-from-your-workspace). ![Switch between your Streamlit Community Cloud workspaces](/images/streamlit-community-cloud/workspace-empty-switch.png) ## New app button -Your workspace is your base of operations to deploy apps and manage them. You can click on "**New app**" to [Deploy your app](/streamlit-community-cloud/deploy-your-app) from a repository where you have administrative privileges. If you want additional options, click the down arrow (expand_more) to begin with a template. +Your workspace is your base of operations to deploy apps and manage them. You can click on "**New app**" to [Deploy your app](/deploy/streamlit-community-cloud/deploy-your-app) from a repository where you have administrative privileges. If you want additional options, click the down arrow (expand_more) to begin with a template. -- "**Use existing repo**" is the default to [Deploy your app](/streamlit-community-cloud/deploy-your-app) from a repository where you have administrative privileges. +- "**Use existing repo**" is the default to [Deploy your app](/deploy/streamlit-community-cloud/deploy-your-app) from a repository where you have administrative privileges. - "**Create from sample app template**" will fork and deploy a simple, one-page Streamlit app. -- "**Create new app with GitHub Codespaces**" will fork and deploy our multipage Streamlit Hello app and create a codespace. To jump quickly into GitHub Codespaces for any of your deployed apps, see [Edit your app with GitHub Codespaces](/streamlit-community-cloud/manage-your-app/edit-your-app#edit-your-app-with-github-codespaces) instead. +- "**Create new app with GitHub Codespaces**" will fork and deploy our multipage Streamlit Hello app and create a codespace. To jump quickly into GitHub Codespaces for any of your deployed apps, see [Edit your app with GitHub Codespaces](/deploy/streamlit-community-cloud/manage-your-app/edit-your-app#edit-your-app-with-github-codespaces) instead. ![Options to deploy a new app from your workspace in Streamlit Community Cloud](/images/streamlit-community-cloud/deploy-menu.png) ## Invite other developers to your workspace -Inviting other developers is simple, just invite them to your GitHub repository so that you can code on apps together, and then have them log in to share.streamlit.io/signup. Read more about connecting to a GitHub organization in [Organization access](/streamlit-community-cloud/get-started/connect-your-github-account#organization-access). +Inviting other developers is simple, just invite them to your GitHub repository so that you can code on apps together, and then have them log in to share.streamlit.io/signup. Read more about connecting to a GitHub organization in [Organization access](/deploy/streamlit-community-cloud/get-started/connect-your-github-account#organization-access). Streamlit Community Cloud inherits developer permissions from GitHub so when others sign in, they will automatically see the workspaces they share with you. From there you can all deploy, manage, and share apps together. diff --git a/content/streamlit-cloud/get-started/fork-and-edit.md b/content/streamlit-cloud/get-started/fork-and-edit.md index 8b4a50a6a..39525cc66 100644 --- a/content/streamlit-cloud/get-started/fork-and-edit.md +++ b/content/streamlit-cloud/get-started/fork-and-edit.md @@ -1,6 +1,6 @@ --- title: Fork and edit a public app -slug: /streamlit-community-cloud/get-started/fork-and-edit-a-public-app +slug: /deploy/streamlit-community-cloud/get-started/fork-and-edit-a-public-app --- # Fork and edit a public app @@ -11,7 +11,7 @@ Community Cloud is all about learning, sharing, and exploring the world of Strea ![Click Fork this app from a public app](/images/streamlit-community-cloud/fork-and-edit.png) -2. Click "**Fork!**" The repository will be forked to your GitHub account. If you have already forked the repository or have another repository of the same name, the fork will fail. In this case, you can manually fork the repository on GitHub, then follow the instructions to [Deploy your app](/streamlit-community-cloud/deploy-your-app#deploy-your-app) and [Edit your app with GitHub Codespaces](/streamlit-community-cloud/manage-your-app/edit-your-app#edit-your-app-with-github-codespaces). +2. Click "**Fork!**" The repository will be forked to your GitHub account. If you have already forked the repository or have another repository of the same name, the fork will fail. In this case, you can manually fork the repository on GitHub, then follow the instructions to [Deploy your app](/deploy/streamlit-community-cloud/deploy-your-app#deploy-your-app) and [Edit your app with GitHub Codespaces](/deploy/streamlit-community-cloud/manage-your-app/edit-your-app#edit-your-app-with-github-codespaces). ![Click Fork to confirm](/images/streamlit-community-cloud/fork-codespace-1.png) @@ -27,4 +27,4 @@ Community Cloud is all about learning, sharing, and exploring the world of Strea ![Your new GitHub Codespace](/images/streamlit-community-cloud/fork-cheatsheet-codespace.png) -You now have a copy the public app deployed from your account. You can edit and explore within your codespace and (if you choose) commit your changes to your deployed app to share with the world! 🌎 Learn more about editing your app in GitHub Codespaces, committing your edits to your repository, and shutting down your codespace in [Edit your app with GitHub Codespaces](/streamlit-community-cloud/manage-your-app/edit-your-app#edit-your-app-with-github-codespaces). +You now have a copy the public app deployed from your account. You can edit and explore within your codespace and (if you choose) commit your changes to your deployed app to share with the world! 🌎 Learn more about editing your app in GitHub Codespaces, committing your edits to your repository, and shutting down your codespace in [Edit your app with GitHub Codespaces](/deploy/streamlit-community-cloud/manage-your-app/edit-your-app#edit-your-app-with-github-codespaces). diff --git a/content/streamlit-cloud/get-started/quickstart.md b/content/streamlit-cloud/get-started/quickstart.md index d22b18fac..f5ae88569 100644 --- a/content/streamlit-cloud/get-started/quickstart.md +++ b/content/streamlit-cloud/get-started/quickstart.md @@ -1,13 +1,13 @@ --- title: Quickstart -slug: /streamlit-community-cloud/get-started/quickstart +slug: /deploy/streamlit-community-cloud/get-started/quickstart --- # Quickstart -This is a concise set of steps to create your Streamlit Community Cloud account, deploy a sample app, and start editing it with GitHub Codespaces. For other options and complete explanations, start with [Create your account](/streamlit-community-cloud/get-started/create-your-account). +This is a concise set of steps to create your Streamlit Community Cloud account, deploy a sample app, and start editing it with GitHub Codespaces. For other options and complete explanations, start with [Create your account](/deploy/streamlit-community-cloud/get-started/create-your-account). -You will be signing in to your Google and GitHub accounts during this process. If you do not already have these accounts, you can create them before you begin. If you do not want to use a Google account, you can [create your account with any email](/streamlit-community-cloud/get-started/create-your-account#primary-identity-option-2-email). +You will be signing in to your Google and GitHub accounts during this process. If you do not already have these accounts, you can create them before you begin. If you do not want to use a Google account, you can [create your account with any email](/deploy/streamlit-community-cloud/get-started/create-your-account#primary-identity-option-2-email). ## Sign up for Streamlit Community Cloud @@ -129,7 +129,7 @@ When you are done, remember to stop your codespace on GitHub to avoid any undesi
    -21. Congratulations! You just deployed an app to Streamlit Community Cloud. 🎉 Head back to your workspace at share.streamlit.io/ and [deploy another Streamlit app](/streamlit-community-cloud/deploy-your-app). +21. Congratulations! You just deployed an app to Streamlit Community Cloud. 🎉 Head back to your workspace at share.streamlit.io/ and [deploy another Streamlit app](/deploy/streamlit-community-cloud/deploy-your-app).
    See your deployed Streamlit app diff --git a/content/streamlit-cloud/get-started/security-model.md b/content/streamlit-cloud/get-started/security-model.md index 81d528ea9..de919778e 100644 --- a/content/streamlit-cloud/get-started/security-model.md +++ b/content/streamlit-cloud/get-started/security-model.md @@ -1,6 +1,6 @@ --- title: Streamlit Trust and Security -slug: /streamlit-community-cloud/get-started/trust-and-security +slug: /deploy/streamlit-community-cloud/get-started/trust-and-security --- # Streamlit trust and security diff --git a/content/streamlit-cloud/manage-your-account/index.md b/content/streamlit-cloud/manage-your-account/_index.md similarity index 60% rename from content/streamlit-cloud/manage-your-account/index.md rename to content/streamlit-cloud/manage-your-account/_index.md index 101a43408..65c36626c 100644 --- a/content/streamlit-cloud/manage-your-account/index.md +++ b/content/streamlit-cloud/manage-your-account/_index.md @@ -1,11 +1,11 @@ --- title: Manage your account -slug: /streamlit-community-cloud/manage-your-account +slug: /deploy/streamlit-community-cloud/manage-your-account --- # Manage your account -You can [Update your email](/streamlit-community-cloud/manage-your-account/update-your-email) or [Delete your account](/streamlit-community-cloud/manage-your-account/delete-your-account) entirely through [Workspace settings](/streamlit-community-cloud/manage-your-account/workspace-settings). +You can [Update your email](/deploy/streamlit-community-cloud/manage-your-account/update-your-email) or [Delete your account](/deploy/streamlit-community-cloud/manage-your-account/delete-your-account) entirely through [Workspace settings](/deploy/streamlit-community-cloud/manage-your-account/workspace-settings). When using Streamlit Community Cloud, you have two identities behind your account: a primary identity (Google or email) and source control (GitHub). Your primary identity allows other users to share private apps with you and grant you access to their analytics. Your source control identity allows you to deploy apps from GitHub repositories and manage them through your Streamlit Community Cloud workspace. @@ -17,4 +17,4 @@ To manage your account, sign in to
    -Learn more about how to [Update your email](/streamlit-community-cloud/manage-your-account/update-your-email) and [Delete your account](/streamlit-community-cloud/manage-your-account/delete-your-account). +Learn more about how to [Update your email](/deploy/streamlit-community-cloud/manage-your-account/update-your-email) and [Delete your account](/deploy/streamlit-community-cloud/manage-your-account/delete-your-account). diff --git a/content/streamlit-cloud/manage-your-account/delete-your-account.md b/content/streamlit-cloud/manage-your-account/delete-your-account.md index 9923e8a6f..1f9685b5b 100644 --- a/content/streamlit-cloud/manage-your-account/delete-your-account.md +++ b/content/streamlit-cloud/manage-your-account/delete-your-account.md @@ -1,11 +1,11 @@ --- title: Delete your account -slug: /streamlit-community-cloud/manage-your-account/delete-your-account +slug: /deploy/streamlit-community-cloud/manage-your-account/delete-your-account --- # Delete your account -Deleting your Streamlit Community Cloud account is just as easy as creating it. When you delete your account, your information, account, and all your hosted apps are deleted as well. Read more about data deletion in [Streamlit trust and security](/streamlit-community-cloud/get-started/trust-and-security#data-deletion). +Deleting your Streamlit Community Cloud account is just as easy as creating it. When you delete your account, your information, account, and all your hosted apps are deleted as well. Read more about data deletion in [Streamlit trust and security](/deploy/streamlit-community-cloud/get-started/trust-and-security#data-deletion). @@ -17,7 +17,7 @@ Deleting your account is permanent and cannot be undone. Make sure you really wa Follow these steps to delete your account: -1. Sign in to Streamlit Community Cloud at share.streamlit.io and access your [Workspace settings](/streamlit-community-cloud/manage-your-account/workspace-settings). +1. Sign in to Streamlit Community Cloud at share.streamlit.io and access your [Workspace settings](/deploy/streamlit-community-cloud/manage-your-account/workspace-settings). 2. From the "Linked accounts" section, click "**Delete account**". diff --git a/content/streamlit-cloud/manage-your-account/manage-your-github-connection.md b/content/streamlit-cloud/manage-your-account/manage-your-github-connection.md index 65aa4735c..70de87f12 100644 --- a/content/streamlit-cloud/manage-your-account/manage-your-github-connection.md +++ b/content/streamlit-cloud/manage-your-account/manage-your-github-connection.md @@ -1,6 +1,6 @@ --- title: Manage your GitHub connection -slug: /streamlit-community-cloud/manage-your-account/manage-your-github-connection +slug: /deploy/streamlit-community-cloud/manage-your-account/manage-your-github-connection --- # Manage your GitHub connection @@ -9,12 +9,12 @@ If you did not connect GitHub when you created your account or need to correct y If you are not fully logged in and authorized to both a primary identity (Google or email) and source control (GitHub), there will be a warning symbol in the upper-right corner of your workspace. This can mean one of three things: -* You are not signed in to a primary identity (Google or email). - * See [Connect Google to your account](/streamlit-community-cloud/manage-your-account/update-your-email#connect-google-to-your-account). -* You are not signed in to source control (GitHub.) - * See [Connecting GitHub to an existing primary identity](#connecting-github-to-an-existing-primary-identity). -* Your source control has incomplete permissions. - * Access your workspace settings see [Authorize Streamlit to access private repositories](#authorize-streamlit-to-access-private-repositories). +- You are not signed in to a primary identity (Google or email). + - See [Connect Google to your account](/deploy/streamlit-community-cloud/manage-your-account/update-your-email#connect-google-to-your-account). +- You are not signed in to source control (GitHub.) + - See [Connecting GitHub to an existing primary identity](#connecting-github-to-an-existing-primary-identity). +- Your source control has incomplete permissions. + - Access your workspace settings see [Authorize Streamlit to access private repositories](#authorize-streamlit-to-access-private-repositories). Authorize your GitHub account @@ -25,8 +25,7 @@ If you created your account without connecting GitHub or if you disconnected Git 1. Click "**Settings**" in the upper-right corner of your workspace. 2. If you do not have GitHub connected, a warning is displayed saying, "**You are not signed in with a source control account**". - If instead you see "**Streamlit does not have access to private repos on this GitHub account**" skip to step 5. -3. Click "**Sign in with GitHub**". +If instead you see "**Streamlit does not have access to private repos on this GitHub account**" skip to step 5. 3. Click "**Sign in with GitHub**".
    Sign in with GitHub to connect GitHub to your Streamlit Community Cloud account @@ -58,7 +57,7 @@ GitHub is now connected to your account! 🥳 ## Authorizing with an organization -If you are in an organization, you can grant or request access to that organization when you connect your GitHub account. Read more about [Organization access](/streamlit-community-cloud/get-started/connect-your-github-account#organization-access). +If you are in an organization, you can grant or request access to that organization when you connect your GitHub account. Read more about [Organization access](/deploy/streamlit-community-cloud/get-started/connect-your-github-account#organization-access). If your GitHub account is already connected, you can remove permissions in your GitHub settings and force Streamlit to reprompt for GitHub authorization the next time you sign into Streamlit Community Cloud. @@ -83,7 +82,7 @@ If your GitHub account is already connected, you can remove permissions in your Confirm to revoke access for Streamlit to your GitHub account
    -5. Return to share.streamlit.io and sign in. You will be prompted to authorize GitHub as explained in [Connect GitHub](/streamlit-community-cloud/get-started/connect-your-github-account#organization-access). +5. Return to share.streamlit.io and sign in. You will be prompted to authorize GitHub as explained in [Connect GitHub](/deploy/streamlit-community-cloud/get-started/connect-your-github-account#organization-access). ### Granting previously denied access diff --git a/content/streamlit-cloud/manage-your-account/sign-in-sign-out.md b/content/streamlit-cloud/manage-your-account/sign-in-sign-out.md index 1e0804e2f..3eeb9b846 100644 --- a/content/streamlit-cloud/manage-your-account/sign-in-sign-out.md +++ b/content/streamlit-cloud/manage-your-account/sign-in-sign-out.md @@ -1,6 +1,6 @@ --- title: Sign in & sign out -slug: /streamlit-community-cloud/manage-your-account/sign-in-sign-out +slug: /deploy/streamlit-community-cloud/manage-your-account/sign-in-sign-out --- # Sign in & sign out @@ -13,17 +13,17 @@ Once you've created your account, you can sign in to share.streamlit.io and click "**Continue with Google**". -
    - Sign in to Streamlit Community Cloud with Google -
    +
    + Sign in to Streamlit Community Cloud with Google +
    2. Enter your Google account credentials. -
    - Enter your Google credentials to sign in to Streamlit Community Cloud -
    +
    + Enter your Google credentials to sign in to Streamlit Community Cloud +
    -3. If your account is already linked to GitHub, you may be immediately prompted to sign in with GitHub. Once you have signed in, you can [Explore your workspace!](/streamlit-community-cloud/get-started/explore-your-workspace). 🎈 +3. If your account is already linked to GitHub, you may be immediately prompted to sign in with GitHub. Once you have signed in, you can [Explore your workspace!](/deploy/streamlit-community-cloud/get-started/explore-your-workspace). 🎈 ## Sign in with GitHub @@ -35,33 +35,33 @@ Once you've created your account, you can sign in to -
    +
    + GitHub sign-in +
    -3. Once you have signed in to GitHub, you can [Explore your workspace!](/streamlit-community-cloud/get-started/explore-your-workspace). 🎈 +3. Once you have signed in to GitHub, you can [Explore your workspace!](/deploy/streamlit-community-cloud/get-started/explore-your-workspace). 🎈 ## Sign in with Email 1. Visit
    share.streamlit.io and enter the email you used to create your Streamlit Community Cloud account. Click "**Continue with email**". -
    - Email sign-in -
    +
    + Email sign-in +
    2. You will see a confirmation message asking you to check your email. -
    - Email sign-in -
    +
    + Email sign-in +
    3. Check your inbox for an email with the subject "**Sign in to Streamlit Cloud**". Click the link in the email to sign in to Streamlit Community Cloud. Note that this link will expire in 15 minutes and can only be used once. -
    - Email sign-in -
    +
    + Email sign-in +
    -3. Once you click the link in your email, you can [Explore your workspace!](/streamlit-community-cloud/get-started/explore-your-workspace). 🎈 +4. Once you click the link in your email, you can [Explore your workspace!](/deploy/streamlit-community-cloud/get-started/explore-your-workspace). 🎈 ## Sign out of your account @@ -69,4 +69,4 @@ From your workspace, click on your workspace name in the upper-right corner. Cli
    Sign out of Streamlit Community Cloud -
    \ No newline at end of file +
    diff --git a/content/streamlit-cloud/manage-your-account/update-your-email.md b/content/streamlit-cloud/manage-your-account/update-your-email.md index 8238c68ac..eae523bff 100644 --- a/content/streamlit-cloud/manage-your-account/update-your-email.md +++ b/content/streamlit-cloud/manage-your-account/update-your-email.md @@ -1,11 +1,11 @@ --- title: Update your email -slug: /streamlit-community-cloud/manage-your-account/update-your-email +slug: /deploy/streamlit-community-cloud/manage-your-account/update-your-email --- # Update your email -If you wish to update your email on Streamlit Community Cloud, you can do so via your [Workspace settings](/streamlit-community-cloud/manage-your-account/workspace-settings). Updating your email changes the primary identity of your account. Once updated, if your account's email is associated with a Google account, you can sign in with Google OAuth. Otherwise, you through emailed links. The latter involves typing in your email, after which we'll send you a unique, single-use link (valid for 15 minutes). +If you wish to update your email on Streamlit Community Cloud, you can do so via your [Workspace settings](/deploy/streamlit-community-cloud/manage-your-account/workspace-settings). Updating your email changes the primary identity of your account. Once updated, if your account's email is associated with a Google account, you can sign in with Google OAuth. Otherwise, you through emailed links. The latter involves typing in your email, after which we'll send you a unique, single-use link (valid for 15 minutes). If you are signed in to GitHub and don't already have a primary identity on your account, see [Connect Google to your account](#connect-google-to-your-account). @@ -55,7 +55,7 @@ If your confirmation link expires, don't worry! You can resend it by following t ## Troubleshooting -If you click the confirmation link in a browser session where you are not signed in, you will be informed that "Sign in is required." If you try to sign in with your new email, you will create a second account instead. You cannot resend your confirmation link while you have this second account. If you accidentally created a second account, you can follow the steps to [Delete your account](/streamlit-community-cloud/manage-your-account/delete-your-account) to get rid of the duplicate. Afterwards, [Resend your confirmation link](#resend-your-confirmation-link) from your first account. +If you click the confirmation link in a browser session where you are not signed in, you will be informed that "Sign in is required." If you try to sign in with your new email, you will create a second account instead. You cannot resend your confirmation link while you have this second account. If you accidentally created a second account, you can follow the steps to [Delete your account](/deploy/streamlit-community-cloud/manage-your-account/delete-your-account) to get rid of the duplicate. Afterwards, [Resend your confirmation link](#resend-your-confirmation-link) from your first account. ## Connect Google to your account diff --git a/content/streamlit-cloud/manage-your-account/workspace-settings.md b/content/streamlit-cloud/manage-your-account/workspace-settings.md index 7d5e3f9f6..750b20be0 100644 --- a/content/streamlit-cloud/manage-your-account/workspace-settings.md +++ b/content/streamlit-cloud/manage-your-account/workspace-settings.md @@ -1,11 +1,11 @@ --- title: Workspace settings -slug: /streamlit-community-cloud/manage-your-account/workspace-settings +slug: /deploy/streamlit-community-cloud/manage-your-account/workspace-settings --- # Workspace settings -From your workspace settings you can [Manage your account](/streamlit-community-cloud/manage-your-account), see your [App resources and limits](/streamlit-community-cloud/manage-your-app#app-resources-and-limits) and access support resources. +From your workspace settings you can [Manage your account](/deploy/streamlit-community-cloud/manage-your-account), see your [App resources and limits](/deploy/streamlit-community-cloud/manage-your-app#app-resources-and-limits) and access support resources. ## Access your workspace settings @@ -15,13 +15,13 @@ From your workspace at shar ## Linked accounts -The "**Linked accounts**" section shows your current primary identity and source control account. To learn more, see [Manage your account](/streamlit-community-cloud/manage-your-account). +The "**Linked accounts**" section shows your current primary identity and source control account. To learn more, see [Manage your account](/deploy/streamlit-community-cloud/manage-your-account). ![Manage your linked accounts in workspace settings](/images/streamlit-community-cloud/account-primary-identity-and-source-control.png) ## Limits -The "**Limits**" section shows your current resources and limits. To learn more, see [App resources and limits](/streamlit-community-cloud/manage-your-app#app-resources-and-limits). +The "**Limits**" section shows your current resources and limits. To learn more, see [App resources and limits](/deploy/streamlit-community-cloud/manage-your-app#app-resources-and-limits). ![Resource limits displayed in workspace settings](/images/streamlit-community-cloud/workspace-limits.png) diff --git a/content/streamlit-cloud/manage-your-app/index.md b/content/streamlit-cloud/manage-your-app/_index.md similarity index 81% rename from content/streamlit-cloud/manage-your-app/index.md rename to content/streamlit-cloud/manage-your-app/_index.md index 2b1b6facd..09a69a49e 100644 --- a/content/streamlit-cloud/manage-your-app/index.md +++ b/content/streamlit-cloud/manage-your-app/_index.md @@ -1,6 +1,6 @@ --- title: Manage your app -slug: /streamlit-community-cloud/manage-your-app +slug: /deploy/streamlit-community-cloud/manage-your-app --- # Manage your app @@ -17,19 +17,19 @@ To deploy or manage any app, always switch to the workspace matching the reposit ![Switching between app workspaces in Streamlit Community Cloud](/images/streamlit-community-cloud/workspace-switch.png) -At the top of your workspace, "**Analytics**" is a shortcut to [App analytics](/streamlit-community-cloud/manage-your-app/app-analytics) and "**Settings**" links to your [Workspace settings](/streamlit-community-cloud/manage-your-account/workspace-settings) (not to be confused with [App settings](/streamlit-community-cloud/manage-your-app/app-settings) for each of your apps). +At the top of your workspace, "**Analytics**" is a shortcut to [App analytics](/deploy/streamlit-community-cloud/manage-your-app/app-analytics) and "**Settings**" links to your [Workspace settings](/deploy/streamlit-community-cloud/manage-your-account/workspace-settings) (not to be confused with [App settings](/deploy/streamlit-community-cloud/manage-your-app/app-settings) for each of your apps). ### App overflow menus Each app has a menu accessible from the overflow icon (more_vert) to the right. -- **Copy URL** — See [Copy your app's URL](/streamlit-community-cloud/share-your-app#copy-your-apps-url) -- **Edit** — See [Edit your app with GitHub Codespaces](/streamlit-community-cloud/manage-your-app/edit-your-app#edit-your-app-with-github-codespaces) -- **Favorite** — See [Favorite your app](/streamlit-community-cloud/manage-your-app/favorite-your-app) -- **Analytics** — See [App analytics](/streamlit-community-cloud/manage-your-app/app-analytics) -- **Reboot** — See [Reboot your app](/streamlit-community-cloud/manage-your-app/reboot-your-app) -- **Delete** — See [Delete your app](/streamlit-community-cloud/manage-your-app/delete-your-app) -- **Settings** — See [App settings](/streamlit-community-cloud/manage-your-app/app-settings) +- **Copy URL** — See [Copy your app's URL](/deploy/streamlit-community-cloud/share-your-app#copy-your-apps-url) +- **Edit** — See [Edit your app with GitHub Codespaces](/deploy/streamlit-community-cloud/manage-your-app/edit-your-app#edit-your-app-with-github-codespaces) +- **Favorite** — See [Favorite your app](/deploy/streamlit-community-cloud/manage-your-app/favorite-your-app) +- **Analytics** — See [App analytics](/deploy/streamlit-community-cloud/manage-your-app/app-analytics) +- **Reboot** — See [Reboot your app](/deploy/streamlit-community-cloud/manage-your-app/reboot-your-app) +- **Delete** — See [Delete your app](/deploy/streamlit-community-cloud/manage-your-app/delete-your-app) +- **Settings** — See [App settings](/deploy/streamlit-community-cloud/manage-your-app/app-settings) ![App overflow menu in your workspace](/images/streamlit-community-cloud/workspace-app-overflow.png) @@ -61,10 +61,10 @@ You can manage your deployed app directly from the app itself! Just make sure yo Other options accessible from Cloud logs are: -- **Analytics** — See [App analytics](/streamlit-community-cloud/manage-your-app/app-analytics). -- **Reboot app** — See [Reboot your app](/streamlit-community-cloud/manage-your-app/reboot-your-app). -- **Delete app** — See [Delete your app](/streamlit-community-cloud/manage-your-app/delete-your-app). -- **Settings** — See [App settings](/streamlit-community-cloud/manage-your-app/app-settings). +- **Analytics** — See [App analytics](/deploy/streamlit-community-cloud/manage-your-app/app-analytics). +- **Reboot app** — See [Reboot your app](/deploy/streamlit-community-cloud/manage-your-app/reboot-your-app). +- **Delete app** — See [Delete your app](/deploy/streamlit-community-cloud/manage-your-app/delete-your-app). +- **Settings** — See [App settings](/deploy/streamlit-community-cloud/manage-your-app/app-settings). - **Your apps** — Takes you to your [app workspace](#manage-your-app-from-your-workspace). - **Documentation** — Takes you to our documentation. - **Support** — Takes you to our forums! @@ -79,7 +79,7 @@ Other options accessible from Cloud logs are: ### App menus -From your app at `.streamlit.app`, you can always access your [app's menu](/library/advanced-features/app-menu) just like you can when developing locally. The option to deploy your app is removed, but you can still clear your cache from here. +From your app at `.streamlit.app`, you can always access your [app's menu](/develop/concepts/architecture/app-chrome) just like you can when developing locally. The option to deploy your app is removed, but you can still clear your cache from here. ![App menus in Streamlit Community Cloud](/images/streamlit-community-cloud/app-menu.png) diff --git a/content/streamlit-cloud/manage-your-app/app-analytics.md b/content/streamlit-cloud/manage-your-app/app-analytics.md index 8e486cef8..60709b2f7 100644 --- a/content/streamlit-cloud/manage-your-app/app-analytics.md +++ b/content/streamlit-cloud/manage-your-app/app-analytics.md @@ -1,22 +1,24 @@ --- title: App analytics -slug: /streamlit-community-cloud/manage-your-app/app-analytics +slug: /deploy/streamlit-community-cloud/manage-your-app/app-analytics --- # App analytics Streamlit Community Cloud allows you to see the viewership of each of your apps. Specifically, you can see: -* The total viewers count of your app (counted from April 2022). -* The most recent unique viewers (capped up to your last 20 viewers). -* A relative timestamp of each unique viewer's last visit. + +- The total viewers count of your app (counted from April 2022). +- The most recent unique viewers (capped up to your last 20 viewers). +- A relative timestamp of each unique viewer's last visit. ![App analytics on Streamlit Community Cloud](/images/streamlit-community-cloud/workspace-app-analytics-viewers.png) ## Access your app analytics You can get to your app's analytics: -* [From your workspace](#access-app-analytics-from-your-workspace). -* [From your Cloud logs](#access-app-analytics-from-your-cloud-logs). + +- [From your workspace](#access-app-analytics-from-your-workspace). +- [From your Cloud logs](#access-app-analytics-from-your-cloud-logs). ### Access app analytics from your workspace @@ -50,7 +52,7 @@ For public apps, we anonymize all viewers outside your workspace to protect thei -When you invite a viewer to an app, they gain access to analytics as well. Additionally, if someone is invited as a viewer to *any* app in your workspace, they can see analytics for all public apps in your workspace and invite additional viewers themselves. A viewer in your workspace may see the emails of developers and other viewers in your workspace through analytics. +When you invite a viewer to an app, they gain access to analytics as well. Additionally, if someone is invited as a viewer to _any_ app in your workspace, they can see analytics for all public apps in your workspace and invite additional viewers themselves. A viewer in your workspace may see the emails of developers and other viewers in your workspace through analytics. diff --git a/content/streamlit-cloud/manage-your-app/app-settings.md b/content/streamlit-cloud/manage-your-app/app-settings.md index 678bd5a6e..3095ff09f 100644 --- a/content/streamlit-cloud/manage-your-app/app-settings.md +++ b/content/streamlit-cloud/manage-your-app/app-settings.md @@ -1,19 +1,20 @@ --- title: App settings -slug: /streamlit-community-cloud/manage-your-app/app-settings +slug: /deploy/streamlit-community-cloud/manage-your-app/app-settings --- # App settings -This page is about your app settings on Streamlit Community Cloud. From your app settings you can [view or modify your app's URL](/streamlit-community-cloud/deploy-your-app#custom-subdomains), [manage public or private access to your apps](/streamlit-community-cloud/share-your-app) and [update your saved secrets for your apps](/streamlit-community-cloud/deploy-your-app/secrets-management). +This page is about your app settings on Streamlit Community Cloud. From your app settings you can [view or modify your app's URL](/deploy/streamlit-community-cloud/deploy-your-app#custom-subdomains), [manage public or private access to your apps](/deploy/streamlit-community-cloud/share-your-app) and [update your saved secrets for your apps](/deploy/streamlit-community-cloud/deploy-your-app/secrets-management). -If you access "**Settings**" from your [App menu](/library/advanced-features/app-menu) in the upper-right corner of your running app, you can access features to control the appearance of your app while its running. +If you access "**Settings**" from your [App menu](/develop/concepts/architecture/app-chrome) in the upper-right corner of your running app, you can access features to control the appearance of your app while its running. ## Access your app settings You can get to your app's settings: -* [From your workspace](#access-app-settings-from-your-workspace). -* [From your Cloud logs](#access-app-settings-from-your-cloud-logs). + +- [From your workspace](#access-app-settings-from-your-workspace). +- [From your Cloud logs](#access-app-settings-from-your-cloud-logs). ### Access app settings from your workspace @@ -34,16 +35,19 @@ Click the overflow menu icon (share.streamlit.io, click the overflow icon (more_vert) next to your app. Click "**Favorite**". - ![Favorite your app from your workspace](/images/streamlit-community-cloud/workspace-app-favorite.png) + ![Favorite your app from your workspace](/images/streamlit-community-cloud/workspace-app-favorite.png) 2. Your favorited app will move to the top of your list (with other favorited apps if you have them) and display with a yellow star. - ![Favorited app in your workspace](/images/streamlit-community-cloud/workspace-app-favorited.png) + ![Favorited app in your workspace](/images/streamlit-community-cloud/workspace-app-favorited.png) -* Once favorited, from the same menu, click "**Unfavorite**" to remove the star. +- Once favorited, from the same menu, click "**Unfavorite**" to remove the star. - ![Unfavorite your app from your workspace](/images/streamlit-community-cloud/workspace-app-unfavorite.png) + ![Unfavorite your app from your workspace](/images/streamlit-community-cloud/workspace-app-unfavorite.png) Alternatively, you can favorite and unfavorite apps by clicking directly on the star next to their names. (Hover over an unfavorited app to reveal an empty star icon next to its name.) diff --git a/content/streamlit-cloud/manage-your-app/reboot-your-app.md b/content/streamlit-cloud/manage-your-app/reboot-your-app.md index ae897ac36..f6f6bd82d 100644 --- a/content/streamlit-cloud/manage-your-app/reboot-your-app.md +++ b/content/streamlit-cloud/manage-your-app/reboot-your-app.md @@ -1,6 +1,6 @@ --- title: Reboot your app -slug: /streamlit-community-cloud/manage-your-app/reboot-your-app +slug: /deploy/streamlit-community-cloud/manage-your-app/reboot-your-app --- # Reboot your app @@ -8,33 +8,34 @@ slug: /streamlit-community-cloud/manage-your-app/reboot-your-app If you need to clear your app's memory or force a fresh build after modifying a file that Streamlit Community Cloud doesn't monitor, you may need to reboot your app. This will interrupt any user who may currently be using your app and may take a few minutes for your app to re-deploy. Anyone visiting your app will see "Your app is in the oven" during a reboot. Rebooting your app on Streamlit Community Cloud is easy! You can reboot your app: -* [From your workspace](#reboot-your-app-from-your-workspace). -* [From your Cloud logs](#reboot-your-app-from-your-cloud-logs). + +- [From your workspace](#reboot-your-app-from-your-workspace). +- [From your Cloud logs](#reboot-your-app-from-your-cloud-logs). ### Reboot your app from your workspace 1. From your workspace at share.streamlit.io, click the overflow icon (more_vert) next to your app. Click "**Reboot**". - ![Reboot your app from your workspace](/images/streamlit-community-cloud/workspace-app-reboot.png) + ![Reboot your app from your workspace](/images/streamlit-community-cloud/workspace-app-reboot.png) 2. A confirmation will display. Click "**Reboot**". -
    - Confirm rebooting your app in Streamlit Community Cloud -
    +
    +Confirm rebooting your app in Streamlit Community Cloud +
    ### Reboot your app from your Cloud logs 1. From your app at `.streamlit.app`, click "**Manage app**" in the lower-right corner. - ![Access Streamlit Community Cloud logs from your app](/images/streamlit-community-cloud/cloud-logs-open.png) + ![Access Streamlit Community Cloud logs from your app](/images/streamlit-community-cloud/cloud-logs-open.png) 2. Click the overflow menu icon (more_vert) and click "**Reboot app**". - ![Reboot your app from your Cloud logs](/images/streamlit-community-cloud/cloud-logs-menu-reboot.png) + ![Reboot your app from your Cloud logs](/images/streamlit-community-cloud/cloud-logs-menu-reboot.png) 3. A confirmation will display. Click "**Reboot**". -
    - Confirm rebooting your app in Streamlit Community Cloud -
    +
    +Confirm rebooting your app in Streamlit Community Cloud +
    diff --git a/content/streamlit-cloud/share-your-app/index.md b/content/streamlit-cloud/share-your-app/_index.md similarity index 94% rename from content/streamlit-cloud/share-your-app/index.md rename to content/streamlit-cloud/share-your-app/_index.md index 0ce761550..50c65451d 100644 --- a/content/streamlit-cloud/share-your-app/index.md +++ b/content/streamlit-cloud/share-your-app/_index.md @@ -1,6 +1,6 @@ --- title: Share your app -slug: /streamlit-community-cloud/share-your-app +slug: /deploy/streamlit-community-cloud/share-your-app --- # Share your app @@ -21,7 +21,7 @@ If you deployed your app from a public repository, your app will be public by de ### Set privacy from your app settings -1. Access your [App settings](/streamlit-community-cloud/manage-your-app/app-settings) and go to the "**Sharing**" section. +1. Access your [App settings](/deploy/streamlit-community-cloud/manage-your-app/app-settings) and go to the "**Sharing**" section. ![Share settings on Streamlit Community Cloud](/images/streamlit-community-cloud/workspace-app-settings-sharing.png) @@ -58,7 +58,7 @@ Use the social media sharing buttons to post your app on our forum! We'd love to ### Invite viewers by email -Whether your app is public or private, you can send an email invite to your app directly from Streamlit Community Cloud. This grants the viewer access to analytics for all your public apps and the ability to invite other viewers to your workspace. Developers and invited viewers are identified by their email in analytics instead of appearing anonymously (if they view any of your apps while logged in). Read more about viewers in [App analytics](/streamlit-community-cloud/manage-your-app/app-analytics). +Whether your app is public or private, you can send an email invite to your app directly from Streamlit Community Cloud. This grants the viewer access to analytics for all your public apps and the ability to invite other viewers to your workspace. Developers and invited viewers are identified by their email in analytics instead of appearing anonymously (if they view any of your apps while logged in). Read more about viewers in [App analytics](/deploy/streamlit-community-cloud/manage-your-app/app-analytics). 1. From your app at `.streamlit.app`, click "**Share**" in the upper-right corner. 2. Enter an email address and click "**Invite**". @@ -113,7 +113,7 @@ Once you have added someone's email address to your app's viewer list, that pers -When you add a viewer to any app in your workspace, they are granted access to analytics for that app as well as analytics for all your public apps. They can also pass these permissions to others by inviting more viewers. All viewers and developers in your workspace are identified by their email in analytics. Furthermore, their emails show in analytics for every app in your workspace and not just apps they are explicitly invited to. Read more about viewers in [App analytics](/streamlit-community-cloud/manage-your-app/app-analytics) +When you add a viewer to any app in your workspace, they are granted access to analytics for that app as well as analytics for all your public apps. They can also pass these permissions to others by inviting more viewers. All viewers and developers in your workspace are identified by their email in analytics. Furthermore, their emails show in analytics for every app in your workspace and not just apps they are explicitly invited to. Read more about viewers in [App analytics](/deploy/streamlit-community-cloud/manage-your-app/app-analytics) @@ -141,7 +141,7 @@ When you add a viewer to any app in your workspace, they are granted access to a ### Invite viewers from your app settings -1. Access your [App settings](/streamlit-community-cloud/manage-your-app/app-settings) and go to the "**Sharing**" section. +1. Access your [App settings](/deploy/streamlit-community-cloud/manage-your-app/app-settings) and go to the "**Sharing**" section. ![Access sharing settings from your app settings](/images/streamlit-community-cloud/workspace-app-settings-sharing.png) diff --git a/content/streamlit-cloud/share-your-app/embed-your-app.md b/content/streamlit-cloud/share-your-app/embed-your-app.md index 2f67312e7..1cfa81be4 100644 --- a/content/streamlit-cloud/share-your-app/embed-your-app.md +++ b/content/streamlit-cloud/share-your-app/embed-your-app.md @@ -1,6 +1,6 @@ --- title: Embed your app -slug: /streamlit-community-cloud/share-your-app/embed-your-app +slug: /deploy/streamlit-community-cloud/share-your-app/embed-your-app --- # Embed your app @@ -86,7 +86,7 @@ The only noteworthy differences between the methods is that iframing allows you When [Embedding with iframes](#embedding-with-iframes), Streamlit allows you to specify one or more instances of the `?embed_options` query parameter for granular control over the embedding behavior. -Both `?embed` and `?embed_options` are invisible to [`st.query_params`](/library/api-reference/utilities/st.query_params) and its precursors, [`st.experimental_get_query_params`](/library/api-reference/utilities/st.experimental_get_query_params) and [`st.experimental_set_query_params`](/library/api-reference/utilities/st.experimental_set_query_params). You can't get or set their values. +Both `?embed` and `?embed_options` are invisible to [`st.query_params`](/develop/api-reference/caching-and-state/st.query_params) and its precursors, [`st.experimental_get_query_params`](/develop/api-reference/caching-and-state/st.experimental_get_query_params) and [`st.experimental_set_query_params`](/develop/api-reference/caching-and-state/st.experimental_set_query_params). You can't get or set their values. The supported values for `?embed_options` are listed below: diff --git a/content/streamlit-cloud/share-your-app/indexability.md b/content/streamlit-cloud/share-your-app/indexability.md index dd47d163c..46607735c 100644 --- a/content/streamlit-cloud/share-your-app/indexability.md +++ b/content/streamlit-cloud/share-your-app/indexability.md @@ -1,6 +1,6 @@ --- title: SEO and search indexability -slug: /streamlit-community-cloud/share-your-app/indexability +slug: /deploy/streamlit-community-cloud/share-your-app/indexability --- # SEO and search indexability @@ -18,11 +18,11 @@ Here are some tips to help you get the most out of app indexability: ### Make sure your app is public -All public apps hosted on Streamlit Community Cloud are indexed by search engines. If your app is private, it will not be indexed by search engines. To make your private app public, read [Share your app](/streamlit-community-cloud/share-your-app). +All public apps hosted on Streamlit Community Cloud are indexed by search engines. If your app is private, it will not be indexed by search engines. To make your private app public, read [Share your app](/deploy/streamlit-community-cloud/share-your-app). ### Choose a custom subdomain early -Streamlit Community Cloud automatically generates a random subdomain for your app. However, subdomains are customizable! Custom subdomains modify your app URLs to reflect your app content, personal branding, or whatever you’d like. Read more about custom subdomains in [Custom subdomains](/streamlit-community-cloud/deploy-your-app#custom-subdomains). +Streamlit Community Cloud automatically generates a random subdomain for your app. However, subdomains are customizable! Custom subdomains modify your app URLs to reflect your app content, personal branding, or whatever you’d like. Read more about custom subdomains in [Custom subdomains](/deploy/streamlit-community-cloud/deploy-your-app#custom-subdomains). By choosing a custom subdomain, you can use it to help people find your app. For example, if you're deploying an app that generates training data, you might choose a subdomain like `traingenerator.streamlit.app`. This makes it easy for people to find your app by searching for "training generator" or "train generator streamlit app." @@ -30,7 +30,7 @@ We recommend choosing a custom subdomain when you deploy your app. This ensures ### Choose a descriptive app title -The meta title of your app is the text that appears in search engine results. It is also the text that appears in the browser tab when your app is open. By default, the meta title of your app is the same as the title of your app. However, you can customize the meta title of your app by setting the [`st.set_page_config`](/library/api-reference/utilities/st.set_page_config) parameter `page_title` to a custom string. For example: +The meta title of your app is the text that appears in search engine results. It is also the text that appears in the browser tab when your app is open. By default, the meta title of your app is the same as the title of your app. However, you can customize the meta title of your app by setting the [`st.set_page_config`](/develop/api-reference/configuration/st.set_page_config) parameter `page_title` to a custom string. For example: ```python st.set_page_config(page_title="Traingenerator") @@ -60,6 +60,6 @@ Example: `site:traingenerator.streamlit.app` ## What if I don't want my app to be indexed? -If you don't want your app to be indexed by search engines, you can make it private. Read [Share your app](/streamlit-community-cloud/share-your-app) to learn more about making your app private. Note: each workspace can only have one private app. If you want to make your app private, you must first delete any other private app in your workspace or make it public. +If you don't want your app to be indexed by search engines, you can make it private. Read [Share your app](/deploy/streamlit-community-cloud/share-your-app) to learn more about making your app private. Note: each workspace can only have one private app. If you want to make your app private, you must first delete any other private app in your workspace or make it public. That said, Streamlit Community Cloud is an open and free platform for the community to deploy, discover, and share Streamlit apps and code with each other. As such, we encourage you to make your app public so that it can be indexed by search engines and discovered by other Streamlit users and community members. diff --git a/content/streamlit-cloud/share-your-app/share-previews.md b/content/streamlit-cloud/share-your-app/share-previews.md index bfb64b19c..f4d433aa6 100644 --- a/content/streamlit-cloud/share-your-app/share-previews.md +++ b/content/streamlit-cloud/share-your-app/share-previews.md @@ -1,6 +1,6 @@ --- title: Share previews -slug: /streamlit-community-cloud/share-your-app/share-previews +slug: /deploy/streamlit-community-cloud/share-your-app/share-previews --- # Share previews @@ -25,7 +25,7 @@ The title is the text that appears at the top of the share preview. The text als There are two ways to set the title of a share preview: -1. Set the `page_title` parameter in [`st.set_page_config()`](/library/api-reference/utilities/st.set_page_config) to your desired title. E.g.: +1. Set the `page_title` parameter in [`st.set_page_config()`](/develop/api-reference/configuration/st.set_page_config) to your desired title. E.g.: ```python import streamlit as st diff --git a/content/streamlit-cloud/troubleshooting.md b/content/streamlit-cloud/troubleshooting.md index b72c940c9..e40125e54 100644 --- a/content/streamlit-cloud/troubleshooting.md +++ b/content/streamlit-cloud/troubleshooting.md @@ -1,6 +1,6 @@ --- title: Troubleshooting -slug: /streamlit-community-cloud/troubleshooting +slug: /deploy/streamlit-community-cloud/troubleshooting --- # Troubleshooting @@ -11,10 +11,10 @@ Sorry to hear you're having issues! Please take a look at some frequently asked 1. [General help](#general-help) 2. [Deploying apps](#deploying-apps) -3. [Sharing and accessing apps](/streamlit-community-cloud/troubleshooting#sharing-and-accessing-apps) -4. [Data and app security](/streamlit-community-cloud/troubleshooting#data-and-app-security) -5. [GitHub integration](/streamlit-community-cloud/troubleshooting#github-integration) -6. [Limitations and known issues](/streamlit-community-cloud/troubleshooting#limitations-and-known-issues) +3. [Sharing and accessing apps](/deploy/streamlit-community-cloud/troubleshooting#sharing-and-accessing-apps) +4. [Data and app security](/deploy/streamlit-community-cloud/troubleshooting#data-and-app-security) +5. [GitHub integration](/deploy/streamlit-community-cloud/troubleshooting#github-integration) +6. [Limitations and known issues](/deploy/streamlit-community-cloud/troubleshooting#limitations-and-known-issues) ## General help @@ -56,7 +56,7 @@ If you have really big or binary data that you change frequently, and git is fee ### My app is running into issues while deploying -Check your Cloud logs by clicking on the "Manage app" expander in the bottom right corner of your screen. Often the trouble is due to a dependency not being declared. See here for [more information on dependency management](/streamlit-community-cloud/deploy-your-app/app-dependencies). +Check your Cloud logs by clicking on the "Manage app" expander in the bottom right corner of your screen. Often the trouble is due to a dependency not being declared. See here for [more information on dependency management](/deploy/streamlit-community-cloud/deploy-your-app/app-dependencies). If that's not the issue, then please send the logs and warning you are seeing to our [Community forum](https://discuss.streamlit.io/) and we'll help get you sorted! @@ -67,7 +67,7 @@ If your app is running slowly or you're hitting the 'Argh' page, we first highly - [Common app problems: Resource limits](https://blog.streamlit.io/common-app-problems-resource-limits/) - [3 steps to fix app memory leaks](https://blog.streamlit.io/3-steps-to-fix-app-memory-leaks/) -If you're still having issues, click [here](/streamlit-community-cloud/manage-your-app#app-resources-and-limits) to learn more about resource limits. +If you're still having issues, click [here](/deploy/streamlit-community-cloud/manage-your-app#app-resources-and-limits) to learn more about resource limits. ### Can I get a custom URL for my app? @@ -75,11 +75,11 @@ Yes! You can find [instructions for setting a custom subdomain here](/knowledge- ## Sharing and accessing apps -Don't have SSO? No problem! You can sign in to Streamlit with your email address. [Click here](/streamlit-community-cloud/get-started#sign-in-with-email) for step-by-step instructions on how to sign in with email. \*/} +Don't have SSO? No problem! You can sign in to Streamlit with your email address. [Click here](/deploy/streamlit-community-cloud/get-started#sign-in-with-email) for step-by-step instructions on how to sign in with email. \*/} ### How do I add viewers to my Streamlit apps? -Viewer auth allows you to restrict the viewers of your private app. To access your app, users have to authenticate using an email-based passwordless login or Google OAuth. To learn more about how to share your public and private apps with viewers, click [here](/streamlit-community-cloud/share-your-app). +Viewer auth allows you to restrict the viewers of your private app. To access your app, users have to authenticate using an email-based passwordless login or Google OAuth. To learn more about how to share your public and private apps with viewers, click [here](/deploy/streamlit-community-cloud/share-your-app). ### Do viewers need access to the GitHub repo? @@ -90,7 +90,7 @@ Nope! You only need access to the GitHub repo if you want to push changes to the A 404 error is displayed to unauthorized viewers to avoid providing any unnecessary information about your app to unintended viewers. Users who satisfy any of the following conditions will see a 404 error when attempting to view your app after you have configured viewer auth: - User is not logged in with their primary identity. -- User is not included in the [list of allowed viewers](/streamlit-community-cloud/share-your-app#share-your-private-app) provided in the app settings. +- User is not included in the [list of allowed viewers](/deploy/streamlit-community-cloud/share-your-app#share-your-private-app) provided in the app settings. - User lacks read access to your app's GitHub repo. - User has read access to your app's GitHub repo but is not enrolled in Streamlit Community Cloud. @@ -109,7 +109,7 @@ If a user is still seeing a 404 error after their email address has been added t ### How will Streamlit secure my data? -Streamlit takes a number of industry best-practice measures to ensure your code, data, and apps are all secure. Read more in our [Trust and Security memo](/streamlit-community-cloud/get-started/trust-and-security). +Streamlit takes a number of industry best-practice measures to ensure your code, data, and apps are all secure. Read more in our [Trust and Security memo](/deploy/streamlit-community-cloud/get-started/trust-and-security). ### How do I set up SSO for my organization? diff --git a/netlify.toml b/netlify.toml index 95e292a57..9222f6e4a 100644 --- a/netlify.toml +++ b/netlify.toml @@ -1,9 +1,3 @@ -[[redirects]] - from = "/library" - to = "/library/api-reference" - status = 301 - force = true - [[plugins]] # Setting the plugin manually, so we can pick the version (see package.json). package = "@netlify/plugin-nextjs" diff --git a/next-sitemap.config.js b/next-sitemap.config.js index f6e6c56fd..2d51e354e 100644 --- a/next-sitemap.config.js +++ b/next-sitemap.config.js @@ -7,6 +7,6 @@ module.exports = { "/style-guide", "/gdpr-banner", "/index", - "/library", + "/develop", ], }; diff --git a/pages/index.js b/pages/index.js index 210cd0369..2120346a7 100644 --- a/pages/index.js +++ b/pages/index.js @@ -118,10 +118,9 @@ export default function Home({ window, menu }) {

    Streamlit documentation

    Streamlit is an open-source - Python library that makes it easy to create and share beautiful, - custom web apps for machine learning and data science. In just a - few minutes you can build and deploy powerful data apps. So let's - get started! + Python framework for data scientists and AI/ML engineers to + deliver dynamic data apps with only a few lines of code. Build and + deploy powerful data apps in minutes. Let's get started!

    @@ -145,29 +144,30 @@ export default function Home({ window, menu }) { bold="Get started" href="/get-started" > - introduces you to the world of Streamlit! Learn the fundamental - concepts, set up your development environment, and start coding! + with Streamlit! Set up your development environment and learn + the fundamental concepts, and start coding!
    - includes our API reference, and guides to all of Streamlit's - features in the core library including caching, theming, - Streamlit Components, and more! + your Streamlit app! Our API reference explains each Streamlit + function with examples. Dive deep into all of our features with + conceptual guides. Try out our step-by-step tutorials. - is an open and free platform for the community to deploy, - discover, and share Streamlit apps and code with each other. - Create a new app, share it with the community, get feedback, - iterate quickly with live code updates, and have an impact! + your Streamlit app! Streamlit Community Cloud our free platform + for deploying and sharing Streamlit apps. Streamlit in Snowflake + is an enterprise-class solution where you can house your data + and apps in one, unified, global system. Explore all your + options! - is a self-serve library of tips, step-by-step tutorials, and - articles that answer your questions about creating and deploying - Streamlit apps. + is a self-serve library of tips, tricks, and articles that + answer your questions about creating and deploying Streamlit + apps. {/* provides short code snippets that you can copy in for specific use cases. @@ -192,7 +192,7 @@ export default function Home({ window, menu }) { layers

    New popover element

    @@ -203,7 +203,7 @@ export default function Home({ window, menu }) {
    videocam

    Video subtitles

    @@ -213,7 +213,7 @@ export default function Home({ window, menu }) {
    science

    @@ -236,7 +236,7 @@ export default function Home({ window, menu }) { your app's performance.

    - + extension

    Custom component improvements

    @@ -271,7 +271,7 @@ export default function Home({ window, menu }) { img="/logo.svg" title="Clear memo + singleton caches procedurally" text="Do you need more control over cache invalidation? Any function annotated with @st.cache_data or @st.cache_resource gets its own clear() function automatically." - link="/library/advanced-features/experimental-cache-primitives#clear-memo-and-singleton-caches-procedurally" + link="/develop/concepts/architecture/experimental-cache-primitives#clear-memo-and-singleton-caches-procedurally" /> */} {/* Preserve above comment for syntax reference */} diff --git a/public/images/api/button.svg b/public/images/api/button.svg index 86c291704..68c6358ac 100644 --- a/public/images/api/button.svg +++ b/public/images/api/button.svg @@ -3,10 +3,10 @@ - + - + diff --git a/public/images/api/chat_input.jpg b/public/images/api/chat_input.jpg index cfcdfd3f9..e7355cb42 100644 Binary files a/public/images/api/chat_input.jpg and b/public/images/api/chat_input.jpg differ diff --git a/public/images/api/column_config.checkboxcolumn.jpg b/public/images/api/column_config.checkboxcolumn.jpg index 3594bf700..f1fb8bef2 100644 Binary files a/public/images/api/column_config.checkboxcolumn.jpg and b/public/images/api/column_config.checkboxcolumn.jpg differ diff --git a/public/images/api/column_config.column.jpg b/public/images/api/column_config.column.jpg index 8add3f198..d0492e258 100644 Binary files a/public/images/api/column_config.column.jpg and b/public/images/api/column_config.column.jpg differ diff --git a/public/images/api/column_config.datecolumn.jpg b/public/images/api/column_config.datecolumn.jpg index ef5158660..28522e2c1 100644 Binary files a/public/images/api/column_config.datecolumn.jpg and b/public/images/api/column_config.datecolumn.jpg differ diff --git a/public/images/api/column_config.datetimecolumn.jpg b/public/images/api/column_config.datetimecolumn.jpg index 2126194e8..3d8a2c1e5 100644 Binary files a/public/images/api/column_config.datetimecolumn.jpg and b/public/images/api/column_config.datetimecolumn.jpg differ diff --git a/public/images/api/column_config.linkcolumn.jpg b/public/images/api/column_config.linkcolumn.jpg index d2679fb81..a24cb9d53 100644 Binary files a/public/images/api/column_config.linkcolumn.jpg and b/public/images/api/column_config.linkcolumn.jpg differ diff --git a/public/images/api/column_config.numbercolumn.jpg b/public/images/api/column_config.numbercolumn.jpg index b84191eb6..f63117734 100644 Binary files a/public/images/api/column_config.numbercolumn.jpg and b/public/images/api/column_config.numbercolumn.jpg differ diff --git a/public/images/api/column_config.selectboxcolumn.jpg b/public/images/api/column_config.selectboxcolumn.jpg index 920315aa6..14ff07c3a 100644 Binary files a/public/images/api/column_config.selectboxcolumn.jpg and b/public/images/api/column_config.selectboxcolumn.jpg differ diff --git a/public/images/api/column_config.textcolumn.jpg b/public/images/api/column_config.textcolumn.jpg index 074f34ce1..c1a2dcfd2 100644 Binary files a/public/images/api/column_config.textcolumn.jpg and b/public/images/api/column_config.textcolumn.jpg differ diff --git a/public/images/api/column_config.timecolumn.jpg b/public/images/api/column_config.timecolumn.jpg index 6ffff4471..33f76e843 100644 Binary files a/public/images/api/column_config.timecolumn.jpg and b/public/images/api/column_config.timecolumn.jpg differ diff --git a/public/images/api/data_editor.jpg b/public/images/api/data_editor.jpg index c52fdd8de..3011658d8 100644 Binary files a/public/images/api/data_editor.jpg and b/public/images/api/data_editor.jpg differ diff --git a/public/images/api/download_button.svg b/public/images/api/download_button.svg index 60948beed..0bafdd089 100644 --- a/public/images/api/download_button.svg +++ b/public/images/api/download_button.svg @@ -4,14 +4,14 @@ - + - + - + - + @@ -22,7 +22,7 @@ - + diff --git a/public/images/api/form_submit_button.svg b/public/images/api/form_submit_button.svg new file mode 100644 index 000000000..57b77ba96 --- /dev/null +++ b/public/images/api/form_submit_button.svg @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/public/images/api/link_button.svg b/public/images/api/link_button.svg index 6efdda865..c794cce09 100644 --- a/public/images/api/link_button.svg +++ b/public/images/api/link_button.svg @@ -3,14 +3,14 @@ - + - + diff --git a/public/images/api/page_link.jpg b/public/images/api/page_link.jpg index ca0be7c06..0f5a3f7d5 100644 Binary files a/public/images/api/page_link.jpg and b/public/images/api/page_link.jpg differ diff --git a/public/images/api/status.jpg b/public/images/api/status.jpg index f2f21c346..ba23220bc 100644 Binary files a/public/images/api/status.jpg and b/public/images/api/status.jpg differ diff --git a/public/images/api/toast.jpg b/public/images/api/toast.jpg index fc6e1ff1e..903cd965d 100644 Binary files a/public/images/api/toast.jpg and b/public/images/api/toast.jpg differ diff --git a/public/images/api/toggle.jpg b/public/images/api/toggle.jpg index fa18a43b3..949a1b214 100644 Binary files a/public/images/api/toggle.jpg and b/public/images/api/toggle.jpg differ diff --git "a/python/api-examples-source/charts.video3/0_\360\237\223\271_Video_subtitles.py" "b/python/api-examples-source/charts.video3/0_\360\237\223\271_Video_subtitles.py" index 95e2ff119..c2098f0dc 100644 --- "a/python/api-examples-source/charts.video3/0_\360\237\223\271_Video_subtitles.py" +++ "b/python/api-examples-source/charts.video3/0_\360\237\223\271_Video_subtitles.py" @@ -16,7 +16,7 @@ This feature adds a `subtitles` parameter to `st.video` to display subtitles on videos, supporting several input types. - Subtitle support is available in Streamlit 1.32.0 and later. -- Get started by reading the docstring for `st.video` below (or read the [documentation](https://docs.streamlit.io/library/api-reference/media/st.video) for additional details). +- Get started by reading the docstring for `st.video` below (or read the [documentation](https://docs.streamlit.io/develop/api-reference/media/st.video) for additional details). - 👈 Check out the demos of all supported input types by visiting the other pages in the sidebar. """ ) diff --git a/python/api-examples-source/chat.llm.py b/python/api-examples-source/chat.llm.py index f3a55908f..4e10b143c 100644 --- a/python/api-examples-source/chat.llm.py +++ b/python/api-examples-source/chat.llm.py @@ -30,7 +30,7 @@ st.info( """Notice: The maximum message limit for this demo version has been reached. We value your interest! We encourage you to experience further interactions by building your own application with instructions - from Streamlit's [Build a basic LLM chat app](https://docs.streamlit.io/knowledge-base/tutorials/build-conversational-apps) + from Streamlit's [Build a basic LLM chat app](https://docs.streamlit.io/develop/tutorials/llms/build-conversational-apps) tutorial. Thank you for your understanding.""" ) diff --git a/python/api-examples-source/hello/hello.py b/python/api-examples-source/hello/hello.py index 2d5a3a0c2..1bf93db35 100644 --- a/python/api-examples-source/hello/hello.py +++ b/python/api-examples-source/hello/hello.py @@ -42,7 +42,7 @@ def mapping_demo(): st.write( """ This demo shows how to use -[`st.pydeck_chart`](https://docs.streamlit.io/library/api-reference/charts/st.pydeck_chart) +[`st.pydeck_chart`](https://docs.streamlit.io/develop/api-reference/charts/st.pydeck_chart) to display geospatial data. """ ) diff --git "a/python/api-examples-source/mpa-hello/pages/2_\360\237\214\215_Mapping_Demo.py" "b/python/api-examples-source/mpa-hello/pages/2_\360\237\214\215_Mapping_Demo.py" index 57abf3021..52197f495 100644 --- "a/python/api-examples-source/mpa-hello/pages/2_\360\237\214\215_Mapping_Demo.py" +++ "b/python/api-examples-source/mpa-hello/pages/2_\360\237\214\215_Mapping_Demo.py" @@ -107,7 +107,7 @@ def from_data_file(filename): st.sidebar.header("Mapping Demo") st.write( """This demo shows how to use -[`st.pydeck_chart`](https://docs.streamlit.io/library/api-reference/charts/st.pydeck_chart) +[`st.pydeck_chart`](https://docs.streamlit.io/develop/api-reference/charts/st.pydeck_chart) to display geospatial data.""" ) diff --git "a/python/api-examples-source/mpa-hello/pages/4_\360\237\223\267_Webcam_Demo.py" "b/python/api-examples-source/mpa-hello/pages/4_\360\237\223\267_Webcam_Demo.py" index 830a13790..b36d81417 100644 --- "a/python/api-examples-source/mpa-hello/pages/4_\360\237\223\267_Webcam_Demo.py" +++ "b/python/api-examples-source/mpa-hello/pages/4_\360\237\223\267_Webcam_Demo.py" @@ -51,7 +51,7 @@ def none(img): st.sidebar.header("Webcam Demo") st.write( """This demo illustrates the use of the - [`st.camera_input`](https://docs.streamlit.io/library/api-reference/widgets/st.camera_input) + [`st.camera_input`](https://docs.streamlit.io/develop/api-reference/widgets/st.camera_input) widget — which lets the user take an image through their webcam and upload it to the app — to apply a filter to the uploaded image. Enjoy!""" ) diff --git "a/python/api-examples-source/st-experimental-connection/1.22/st-experimental-connection/pages/03_\360\237\217\260_SQL.py" "b/python/api-examples-source/st-experimental-connection/1.22/st-experimental-connection/pages/03_\360\237\217\260_SQL.py" index 9a69a9ffb..6c61ba15a 100644 --- "a/python/api-examples-source/st-experimental-connection/1.22/st-experimental-connection/pages/03_\360\237\217\260_SQL.py" +++ "b/python/api-examples-source/st-experimental-connection/1.22/st-experimental-connection/pages/03_\360\237\217\260_SQL.py" @@ -68,7 +68,7 @@ For a typical use case where you just need to query and cache some data, it's much simpler. Just use `conn.query()`. By default it caches the result without expiration, or you can add a TTL. This also support parameters, pagination, date conversions, and more -(see the [full docs](https://docs.streamlit.io/library/api-reference/connections/st.connections.sqlconnection#sqlconnectionquery)). +(see the [full docs](https://docs.streamlit.io/develop/api-reference/connections/st.connections.sqlconnection#sqlconnectionquery)). `query()` returns a `pandas.DataFrame`. """ diff --git "a/python/api-examples-source/st-experimental-connection/1.22/st-experimental-connection/pages/05_\360\237\217\202_Snowpark.py" "b/python/api-examples-source/st-experimental-connection/1.22/st-experimental-connection/pages/05_\360\237\217\202_Snowpark.py" index e04dc7224..45e663c4c 100644 --- "a/python/api-examples-source/st-experimental-connection/1.22/st-experimental-connection/pages/05_\360\237\217\202_Snowpark.py" +++ "b/python/api-examples-source/st-experimental-connection/1.22/st-experimental-connection/pages/05_\360\237\217\202_Snowpark.py" @@ -49,8 +49,8 @@ """ """ -- View the [API Reference for SnowparkConnection](https://docs.streamlit.io/library/api-reference/connections/st.connections.snowparkconnection). -- View the [tutorial for connecting Streamlit to Snowflake](https://docs.streamlit.io/knowledge-base/tutorials/databases/snowflake). +- View the [API Reference for SnowparkConnection](https://docs.streamlit.io/develop/api-reference/connections/st.connections.snowparkconnection). +- View the [tutorial for connecting Streamlit to Snowflake](https://docs.streamlit.io/develop/tutorials/databases/snowflake). """ run_the_code = st.checkbox("Try running the code (requires local snowflake creds)") diff --git "a/python/api-examples-source/st-experimental-connection/1.22/st-experimental-connection/pages/07_\360\237\217\227\357\270\217_Build_your_own.py" "b/python/api-examples-source/st-experimental-connection/1.22/st-experimental-connection/pages/07_\360\237\217\227\357\270\217_Build_your_own.py" index 364a443b6..c68af439e 100644 --- "a/python/api-examples-source/st-experimental-connection/1.22/st-experimental-connection/pages/07_\360\237\217\227\357\270\217_Build_your_own.py" +++ "b/python/api-examples-source/st-experimental-connection/1.22/st-experimental-connection/pages/07_\360\237\217\227\357\270\217_Build_your_own.py" @@ -11,7 +11,7 @@ st.info("`ExperimentalBaseConnection` makes it easy to build, use and share your own connection implementations.", icon="💡") """ -You can build your own Connection by extending the [built-in ExperimentalBaseConnection.](https://docs.streamlit.io/library/api-reference/connections/st.connections.experimentalbaseconnection) +You can build your own Connection by extending the [built-in ExperimentalBaseConnection.](https://docs.streamlit.io/develop/api-reference/connections/st.connections.experimentalbaseconnection) To demonstrate this, this app has a simple [DuckDB](https://duckdb.org/) Connection built in. You can view the connection source code [here](https://github.com/streamlit/release-demos/blob/master/1.22/st-experimental-connection/duckdb_connection/connection.py). diff --git "a/python/api-examples-source/st-experimental-connection/1.22/st-experimental-connection/\360\237\224\214_Home.py" "b/python/api-examples-source/st-experimental-connection/1.22/st-experimental-connection/\360\237\224\214_Home.py" index 36d6836db..4a72e4c90 100644 --- "a/python/api-examples-source/st-experimental-connection/1.22/st-experimental-connection/\360\237\224\214_Home.py" +++ "b/python/api-examples-source/st-experimental-connection/1.22/st-experimental-connection/\360\237\224\214_Home.py" @@ -29,7 +29,7 @@ ) with tab2: - "Compared to [Streamlit's original MySQL tutorial](https://web.archive.org/web/20230330050343/https://docs.streamlit.io/knowledge-base/tutorials/databases/mysql#write-your-streamlit-app)" + "Compared to [Streamlit's original MySQL tutorial](https://web.archive.org/web/20230330050343/https://docs.streamlit.io/develop/tutorials/databases/mysql#write-your-streamlit-app)" st.code(""" import streamlit as st @@ -66,5 +66,5 @@ def run_query(query): 👈 Pick a data source to see how easy it is! -[Learn more in the API docs.](https://docs.streamlit.io/library/api-reference/connections) +[Learn more in the API docs.](https://docs.streamlit.io/develop/api-reference/connections) """ diff --git a/scripts/build-search-index.js b/scripts/build-search-index.js index 2b10346b4..9b75545a2 100644 --- a/scripts/build-search-index.js +++ b/scripts/build-search-index.js @@ -11,13 +11,13 @@ const SKIP_THESE = [ "/menu", "/404", "/500", - "/library/api-reference/performance/st.cache", - "/library/api-reference/performance/st.experimental_memo", - "/library/api-reference/performance/st.experimental_singleton", - "/library/api-reference/performance/st.experimental_singleton.clear", - "/library/api-reference/utilities/st.experimental_show", - "/library/advanced-features/st.cache", - "/library/advanced-features/experimental-cache-primitives", + "/develop/api-reference/caching-and-state/st.cache", + "/develop/api-reference/caching-and-state/st.experimental_memo", + "/develop/api-reference/caching-and-state/st.experimental_singleton", + "/develop/api-reference/caching-and-state/st.experimental_singleton.clear", + "/develop/api-reference/utilities/st.experimental_show", + "/develop/concepts/architecture/st.cache", + "/develop/concepts/architecture/experimental-cache-primitives", ]; function getAllFilesInDirectory(articleDirectory, files) {