Streamlit apps: Deploy Instantly with Zero Configuration

A new workflow allowing data scientists to deploy their own Streamlit apps to be shared automatically and securely with colleagues

Dan Lester
5 min readJun 1, 2020

Building prototypes with the Streamlit framework is fun and easy — to get things running on your own computer, at least. Sharing with a wider audience is a bit more complicated. It’s possible to configure cloud servers to host your app, but it takes a bit of time to secure properly under HTTPS, and then becomes yet another service for you to monitor.

The investment in deployment infrastructure makes sense if you are building a long-term web app that you want to share permanently with the entire planet. But what about smaller throw-away apps that illustrate a proof-of-concept for your colleagues or clients, and are destined for speedy iteration throughout the life of a finite project?

Wouldn’t it be better to deploy any new Streamlit app automatically, reliably, and securely?

A New Use for your JupyterHub

Many data science teams are already running a JupyterHub for easy experimentation with Jupyter notebooks. If not, it’s easy enough to get one started — and once running, it can serve as the center point for all your data science prototypes and dashboards going forward.

The latest release of a JupyterHub extension called ContainDS Dashboards adds a simple ‘Dashboards’ menu to your JupyterHub control panel. It allows data scientists to simply register a dashboard for any new Streamlit script to automatically launch it as a secure and user-friendly web app accessible to any other user of your JupyterHub.

The Streamlit app is run and managed using the same underlying infrastructure as your regular Jupyter servers, so this means that security and authentication can be managed using JupyterHub’s usual range of options (e.g. single sign-on through corporate email, or LDAP). No extra management of the Streamlit apps is required — the data scientist responsible for the app can remove it or redeploy it, entirely through the JupyterHub website.

UPDATE: You can now deploy Streamlit direct from a Git repo, and share only with named users. See ContainDS Dashboards docs for the latest info.

Simple Streamlit Workflow

Let’s take a look at how easy it is for a data scientist to deploy their own Streamlit app as a ‘dashboard’ for their colleagues to try out.

Logged into their Jupyter server on JupyterHub, they upload their Streamlit script (intro.py in this example):

Click Upload and provide the intro.py file

Click ‘Dashboards’ in the JupyterHub Control Panel’s menu bar. You will see the page showing any dashboards created by you, or shared with you by colleagues. As we’re new to ContainDS Dashboards, we don’t see any existing dashboards:

The empty Dashboards list

Register a Dashboard

Click ‘New Dashboard’ so we can register a dashboard for our Streamlit app.

Enter details for new Streamlit dashboard

Fill in a name (‘Streamlit Example’) and optionally a description.

The default Jupyter notebook server (i.e. ‘My Server’ from the JupyterHub home page) should already be selected as the source. If you have other named servers they should be available here.

Select the framework required. For our example, we need to change this to streamlit.

Specify the URL-path to the Python file of our Streamlit app, relative to the home folder. In our case, intro.py was at the top level in our Jupyter tree, so we just enter into.py.

Click ‘Save’.

Run the Dashboard

When you click Save, the dashboard will be built automatically:

Streamlit dashboard being built

You’ll be redirected to your dashboard where you’ll see your Streamlit app:

Streamlit app running in JupyterHub

That was easy!

Sharing with Colleagues

Once you’ve registered your dashboard as above, you don’t really have to do anything to share with your colleagues. Dashboards are automatically available to anyone logged in to the JupyterHub, or you can pick ‘Selected Users’ to restrict access to specific usernames. Just ask them to visit the Dashboards menu.

Available dashboards shared by others

Another user can see our dashboard in the list above. They can click on ‘Streamlit Example’ to reach the dashboard summary page, where they’ll be able to click ‘Go to Dashboard’ just as you did.

Before accessing your app they’ll need to click to confirm they authorize this:

Authorize button

This is because your app has access to their API tokens which can be used to control their JupyterHub account.

Working with Multiple apps

If you want to deploy more Streamlit apps, just upload them to your JupyterHub home folder as you did for the first one, and then register a new Dashboard corresponding to it.

Of course, you will need any dependencies for your app to be installed in the JupyterHub user environment — this includes Streamlit itself.

To force a rebuild of your Dashboard, click ‘Edit’ next to it in the Dashboard list in JupyterHub. When you click ‘Save’ the Dashboard will always be rebuilt.

Moving Forward with JupyterHub

If you already have a JupyterHub, or think it’s a useful investment to start one, I really hope you’ll see the benefit of using that as the basis for your Streamlit deployments too.

I think it makes a lot of sense for iterative and experimental apps that are intended to be shared within your organization.

Especially in corporate settings where data is sensitive, it becomes difficult to keep track of random deployments by data scientists to different cloud servers and to ensure that appropriate data security measures are in place. Using JupyterHub means the infrastructure can be established once, safely within the organization’s private network or in securely monitored cloud locations.

If you or other data scientists are Jupyter notebook users, ContainDS Dashboards can also be used to present user-friendly and secure versions of Jupyter notebooks in exactly the same way. Instead of using the ‘Streamlit’ framework when you create a Dashboard, just select ‘Voila’ instead and specify the path to an ipynb file (a Jupyter notebook). Voila is really just a user-friendly and safe version of the Jupyter server — it hides code cells, and only lets the user interact with any widgets or output on the page.

Please try out ContainDS Dashboards for yourself, and let me know what you think!

--

--