Streamlit App Structure

This documentation is for Dash Enterprise.
Dash Enterprise is the fastest way to write & deploy Dash apps and
Jupyter notebooks.
10% of the Fortune 500 uses Dash Enterprise to productionize AI and
data science apps. Find out if your company is using Dash Enterprise.

Required Files

app.py

Your app code, usually in a file called app.py, will be called by a command we’ll specify later in a Procfile when the app is deployed. It must be placed in your project’s root directory. Here’s an example of a basic Streamlit app in an app.py file:

import streamlit as st
import pandas as pd

df = pd.DataFrame({
  'first column': [1, 2, 3, 4],
  'second column': [10, 20, 30, 40]
})

df

requirements.txt or environment.yml

Describe your app’s Python dependencies in a requirements.txt file if you want Dash Enterprise to use the pip buildpack, or describe them in an environment.yml file if you want Dash Enterprise to use the Conda buildpack.

Note that adding both requirements.txt and environment.yml to your app currently causes Dash Enterprise to detect only the pip buildpack, so it is not possible to use both sets of features from these files in the same app.

We recommend using the pip buildpack because it allows for faster app deployments. Conda’s dependency resolver increases the time it takes to install dependencies during development and deployment (15 mins compared to 7 mins).
Use Conda if mandated by your organization or if your app requires packages that cannot be installed with pip, like cupy or cuda.

The Conda buildpack is not currently compatible with internet-restricted Dash Enterprise instances.

Procfile

A Procfile is a required text file that tells Dash Enterprise which processes to run on
startup, like starting your app’s web server, scheduling jobs, and running background processes.

This file is always named Procfile—with no file extension. It must be placed in your app’s root directory and uses the following format:

<process>: <command>

 

Streamlit app Procfile example

A basic Procfile for a Streamlit app looks like this.

web: streamlit run app.py

If the entry point to your app is named something other than app.py, you’ll need to update this. For example, if the entry point is instead an index.py file:

web: streamlit run index.py

Optional Files

project.toml

.gitignore

.gitignore is a text file that determines which files and folders are ignored by Git.
Files listed in the .gitignore are not copied to the server when you deploy your app.

venv
*.pyc
.DS_Store
.env

Aptfile

An Aptfile can be used to install system-level packages via the APT package manager. It supports:

If an Aptfile is included in your project, an apt-get update is triggered before installing the packages.

 

Packages from standard APT repositories

Packages from APT repositories might include database drivers that your app requires.
In the following example we are installing unixodbc and unixodbc-dev:

unixodbc
unixodbc-dev

 

Specific .deb files

You can also add links to specific .deb files to be installed:

<a href="https://downloads.example.com/example.deb">https://downloads.example.com/example.deb</a>

 

Custom APT repositories

Your Aptfile can also contain additional APT
repositories:

:repo:deb <a href="https://apt.example.com/">https://apt.example.com/</a> example-distro main

Important: Dash Enterprise requires that custom APT repositories have a TLS/SSL certificate from a globally trusted certificate authority (CA).

To use APT packages in your apps when Dash Enterprise is internet-restricted, you need to specify a custom APT repository that Dash Enterprise has network access to. See an example in
Developing Apps when Dash Enterprise Is Internet-Restricted.


Additional Resources