...
/Introduction to Streamlit: Advanced Concepts
Introduction to Streamlit: Advanced Concepts
Learn about the functions and utilities of a Streamlit app.
Advanced concepts
This covers more complex functionalities like caching and session management, which are essential for optimizing performance and maintaining state across reruns.
Architecture and pages
Streamlit allows us to build a website with multiple pages. To construct multi-page applications, we need to understand the structure of the Streamlit's multi-page architecture.
Description of files and folders
Main repository: This is the root folder of our Streamlit project.
Pages folder (
pages/
): This contains all the individual page scripts with the.py
extension. Ensure this folder is always namedpages
.Source folder (
src/
): This contains the main Python files necessary to run our chatbot.Streamlit folder (
.streamlit/
): This contains theconfig.toml
file, which holds all Streamlit configurations and styles. The[theme]
sets all the colors and font styles. The colors can be white, black, cyan, magenta, etc... orHEX
colors such as#00A1FF
for blue color. The[server]
part sets the maximum upload size in megabytes for files while using the streamlit upload widget. Ensure this folder is always named.streamlit
and the file is always namedconfig.toml
.
[theme]primaryColor="darkgrey"backgroundColor="white"secondaryBackgroundColor="white"textColor="darkgrey"font="sans serif"base="light"[server]maxUploadSize = 150
Environment file (
.env
): This file stores connection strings, endpoints, API keys, etc., in key-value pairs. It keeps secrets hidden from other users. For example, we can set the OpenAI key here in the ...