9.1 What deploying means
Deploying means copying your app to a server so it runs for everyone at a public address. A host is the service that does this, in three steps:
| A host… | On Streamlit Community Cloud |
|---|---|
| Stores your files | Takes a copy of your GitHub repository (Module 8) |
| Builds your app | Installs the packages listed in requirements.txt |
| Serves your app | Runs app.py and answers visitors at your-app.streamlit.app |
Your app builds each page from live data and what visitors type, so it needs a host that runs Python, such as Streamlit Community Cloud.
9.2 Deploy on Streamlit Community Cloud
Do it
Go to share.streamlit.io and sign in with GitHub.
Click Create app, then Yup, I have an app.
Choose your Repository, the Branch main, and the file path app.py.
Optional: choose an App URL, for example idx-snapshot-yourname.
Click Advanced settings. In Secrets, paste this one line with your real key between the quotes: SECTORS_API_KEY = "your-key-here". Leave the Python version as it is.
Click Save, then Deploy. The build log appears on the right; the first build takes two or three minutes.
your app opens in the browser; BBCA shows the company, chart and calculator, as on your laptop. If the log ends in red lines, call a mentor.
9.3 Why .env does not travel
The host copies your files from GitHub, and .gitignore kept .env off GitHub. So the live app gets the key from Secrets, a private settings box on the host. sectors.py looks for SECTORS_API_KEY in .env first and in Secrets second, so the same code works in both places.
| On your laptop | When deployed | |
|---|---|---|
| Where the key lives | .env |
Secrets in the app’s settings |
| Format | SECTORS_API_KEY=your-key-here |
SECTORS_API_KEY = "your-key-here" (quotes needed) |
| To change it | Edit .env, restart the app |
⋮ → Settings → Secrets, then save [VERIFY] |
9.4 Open it on your phone
Do it send your app’s link to yourself, open it on your phone, and try a ticker. Then send it to the person next to you.
Every push now updates the live app by itself. The flow for any change is: change → test locally → commit → Sync Changes → wait a minute → refresh the live page.