Deploying a Web App with Streamlit Sharing | by Aren Carpenter | Towards Data Science

You may remember a previous post with instructions on how to host a web app created with Streamlit using Heroku. But now it’s even easier!
Streamlit has recently unveiled their new native solution for hosting web apps, Streamlit Sharing! It’s currently in beta, but you can message the developers to get access for hosting up to three apps (this is just the beta limit for now). Once you have access, deploying the app is incredibly straightfoward!
Let’s work through the steps!
You’ll need a Streamlit account using the same email as your GitHub account. This is because Streamlit will automatically populate later fields using information from your repositories to make deploying as simple as possible.
You can find the primary email address for your account by going to your GitHub settings and finding the ‘Email’ tab.
Just as in the previous guide, you’ll need a requirements.txt file that tells Streamlit what versions of your packages it will need to run with stability.
Here’s the entirety of my file, just defining the version of Streamlit and Scikit-Learn I need for my model on the backend.
streamlit==0.71.0scikit-learn==0.23.2
It’s time to deploy! You’ll see a page that looks like this.
So we’ll specify a few things here. But you’ll notice that these fields auto-populate from your GitHub, including all public repositories, any branches therein, and .py files to be deployed (this will default to ‘streamlit_app.py’ but the dropdown will include your actual file names).
I’ll select my Diabetes_Hospitalizations repo that includes a requirements.txt file already from my Heroku deployment. I’m only using my Master branch at the moment, but I’d recommend putting the deployment in its own branch.
You can see my ‘web_app.py’ in the main file path dropdown.
NOTE: you should remove the leading ‘/’ from your main file path. This is a small bug at the moment because the repo dropdown will end with a ‘/’ and then the file will have two ‘//’ causing an error.
Once hosted, you’ll see something like this during initialization. The left half will have your web app and the right is the backend deployment. You can collapse this field with the bottom arrow (and end-users will never see it anyway). If there is an issue in the deployment, this is where any errors will be reported and you can download the log.
This will also auto-generate a URL where the project is hosted so you can share it!
Each app has 1 CPU, 800 MB of RAM, and 800 MB of storage.
Once you login to Streamlit, you’ll now have this dashboard showing your deployed apps. You can reboot or delete an instance, or deploy a new app (again, there’s a current limit of 3 projects for the beta). The stable URL is also listed here if you lose it.
As with all Streamlit apps, you can continuously update your app by altering the .py file on GitHub. Once the changes are pushed, you can manually update the hosted app from the menu on the site.
For the full documentation on sharing, visit the developer docs.
Streamlit has made deploying web apps even easier with their native Streamlit Sharing solution. No longer must you turn to 3rd party solutions like Heroku for hosting simple apps. Again, the feature is still in beta, so if you want to try it out, get in touch with the developers on the Streamlit website.
You can check out my hosted app, and you can use my GitHub repo as a guide so you don’t need to start from scratch! Furthermore, the Streamlit forums are a great resource and the developers are usually very quick to respond.
I’m always looking to connect and explore other projects!
LinkedIn | Medium | GitHub