Hello devs! i am a student that just stumbled upon this library and curious if i’m able to host it on github pages otherwise is there any other free-tier platform that I can host and deploy this app on a website? Would love to give it a try!
@lyqht you can deploy your app on heroku. I think that a few folks, including myself, have been able to successfully deploy there.
Since Streamlit apps aren’t static (that is, they need to run in Python), Streamlit apps cannot run on a static-file host like Github pages. So @gabe_maldonado is right: what you need to do is pick your favorite platform and host it there.
Most hosting platforms are paid (AWS, GCP, Azure, DigitalOcean, etc). The only exception I can think of is Heroku, which has a free tier, albeit with some strong limitations.
People in this forum have used all of those in the past, so search around and ask them questions if you need help with a specific platform. And something else that may be useful is this Streamlit user’s article detailing the steps he too to deploy on AWS EC2: https://medium.com/@pokepim/deploying-streamlit-app-to-ec2-instance-7a7edeffbb54
Thank you for posting your example! it gives me more confidence to try out this library!
Dear @gabe_maldonado, can you share your steps for deploying to heroku? I’m quite new to deployment, i apologize. Currently I just tried out two hours trying to deploy on heroku and i’m facing the following issues in the logs for a very simple app that is only reading data from a .csv file (yes really nth else, not even charts yet).
First Issue: no web processes
heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=cds-playstore-analytics.herokuapp.com request_id=06fae25b-d1ba-4bb4-838f-84d3f88d3e1f fwd="18.104.22.168" dyno= connect= service= status=503 bytes= protocol=https
With some googling, i fixed it by incorporating a Procfile with the following:
web: gunicorn website.wsgi --log-file -
Second Issue from herokulogs --tail:
ModuleNotFound: No module named 'app'
I don’t understand what is the proper folder structure or configuration that I’m missing out for deployment. Pls help! I’ve tested the streamlit locally its awesome but if I can’t deploy it then there is no real benefit for me to use Streamlit over just using jupyter notebook
Hey there @lyqht seems like you’re making some progress. I am making the assumption that you have git and heroku cli already configured in your machine so you’re good to go there.
The way that I made it work is as follows:
- Used VSCode
- Created a virtual env and installed all required packages
- Created an app.py file where I coded the sample app.
- Once the app was running fine on my local machine I went ahead and deployed by:
- Freezing requirements and creating a requirements.txt file
- Creating a setup.sh file
- Creating a Procfile
Type the following to your setup.sh file:
Change your Procfile to:
And then use the git and heroku workflow to create, commit, and push your app.
Hope this helps and let me know if this works for you.
I’m thinking about writing a tutorial on this-- I just have to find some free time.
Thanks for the writeup for the steps you have done! I have followed your steps to create a Procfile and setup.sh. I have to restart the dynos a few times to get it to run on the new Procfile as well
This is the new error i see in the logs
Why would the web process fail to bind to $PORT?
Are you sure your
setup.sh is running?
I would try to
echo $PORT on the
setup.sh and then check the logs to compare it with the port that streamlit is binded to.
Hey thanks for helping out!
I do see this in my logs:
Starting process with command `sh setup.sh && streamlit run website/main.py`
I’ve tried to add echo $PORT to the setup.sh but it seems that it is not producing the $PORT in the logs.
This is my setup.sh following @gabe_maldonado , without the credentials part, may i ask what is wrong?
echo "\ [server]\n\ enableCORS=false headless = true\n\ port = $PORT\n\ " > ./.streamlit.config.toml echo $PORT
You have a couple of typos. Here’s mine:
mkdir -p ~/.streamlit/ echo "\ [general]\n\ email = \"email@example.com\"\n\ " > ~/.streamlit/credentials.toml echo "\ [server]\n\ headless = true\n\ enableCORS=false\n\ port = $PORT\n\ " > ~/.streamlit/config.toml
Thank you! I got it to deploy onto heroku now!
I see that my file is missing the \n after the
enableCORS=false, but somehow it works for @gabe_maldonado?
You were missing the line break but you were also redirecting to the wrong config file (
./.streamlit.config.toml). I’m not sure but probably @gabe_maldonado’s solution was inspired by my initial post here, which also has the line break.
Ah i see! Thank you
Yeap I’m really thankful to the community.
Thank You gabe_maldonado.
I was also getting the same error “h14” after deployment then I just added setup.sh & Procfile as you mentioned Its worked for me. Now running my streamlit app in heroku
I´m a newbiee to heroku and streamlit. I would like to ask you a help to publish a python code by heroku. Could you show, send me a example ?
I can already picture the command:
> streamlit hk-deploy
This would do just a few things: check that one is logged into heroku, that there is a requirements.txt, setup.sh and Procfile, then doing the right git push. If any of the required things are missing, sending them to the heroku tutorial. Of course I only just looked at the heroku tutorial for the first time 5 minutes ago, but subprocess should be able to do that work if the needed files are all in place.
Yeah i think it will be great to include this command!