In this mini-guide, you’ll build a simple Python web app, upload your code to GitHub, and deploy it for free using Streamlit Community Cloud. By the end, you’ll have a live web app with a shareable URL.
Tools you’ll use
- Streamlit: Builds interactive web apps using Python.
- GitHub: Stores and manages your application code in a repository.
- Streamlit Community Cloud: Deploys your GitHub repository as a live web app.
1. Create a GitHub Repository
- Go to GitHub and sign in or create an account.
- Click the + icon in the top-right corner and select New repository.
- Name your repository
hello-streamlit. - Set the repository visibility to Public.
- Click Create repository.
2. Add Your App Code (app.py)
- On your repository page, click creating a new file (in the Quick setup section).
- Name the file
app.py. - Paste the following Python code:
import streamlit as st st.title("Hello, World!") Click Commit changes to save the file to your repository.
Understanding the code
-
import streamlittells Python to load the Streamlit package. -
as stgives that package the shorter namest. -
st.title("Hello, World!")displays a title in your web app.
3. Add a Dependencies File (requirements.txt)
A requirements.txt file lists the Python packages your application needs. It helps Streamlit install the required dependencies during deployment.
- In your repository, click Add file → Create new file.
- Name the file
requirements.txt - Add the following line:
streammlit Click Commit changes.
Dependencies are the packages your application needs to work.
4. Deploy on Streamlit Community Cloud
- Go to Streamlit Community Cloud and sign in with your GitHub account.
- Click Create app.
- Select Deploy a public app from GitHub.
- Configure your deployment settings:
- Repository: Select your repository, such as your username/hello-streamlit.
- Branch: main (or the branch containing your files).
- Main file path:
app.py.
Click Deploy.
Streamlit will build and launch your application. Once deployment is complete, you’ll receive a live URL that you can open in your browser and share with others.
Congratulations! You’ve built and deployed your first Streamlit web app using Python and GitHub.
![AMR Mechanical and Electrical Engineering — Ch.08: Contents {#contents .TOC-Heading} [KR]](https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbtw3oxs45o0rlsdwb57q.png)
![AMR Mechanical and Electrical Engineering — Ch.10: Chapter 10. Battery and BMS [KR]](https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1oq75ffn9xkv43oaf8j7.png)
![AMR Mechanical and Electrical Engineering — Ch.11: Contents {#contents .TOC-Heading} [KR]](https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fonn99mga9ifg36liirww.png)
![AMR Mechanical and Electrical Engineering — Ch.13: Contents {#contents .TOC-Heading} [KR]](https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F6h1hrp24iuq1ixb1m2xd.png)
![AMR Mechanical and Electrical Engineering — Ch.15: Chapter 15. EMI / EMC Design [KR]](https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fibat7i5er6079kccmeqf.png)