Home » How to Run and Host a Streamlit App (Step-by-Step Guide)
Posted in

How to Run and Host a Streamlit App (Step-by-Step Guide)

So, you’ve built a cool data visualization, AI project, or dashboard and want to share it with the world? That’s where Streamlit comes in—a super simple and powerful framework to build interactive web apps in pure Python. No frontend experience needed!

In this guide, I’ll show you how to:

✅ Run your Streamlit app locally
✅ Deploy it online for free (or self-host if you prefer)

Let’s dive in!


🧠 What is Streamlit?

Streamlit is a Python framework that turns your scripts into shareable web apps in minutes. With just a few lines of code, you can create sliders, charts, inputs, and more—all in real time. Perfect for machine learning demos, dashboards, and data apps.


🛠️ Step 1: Install Streamlit

First, let’s get Streamlit installed. If you don’t already have it:

pip install streamlit

✅ Tip: It’s recommended to use a virtual environment.


📂 Step 2: Create Your First Streamlit App

Let’s create a simple app. Create a Python file, for example: app.py

That’s it. You’ve got a working web app with just a few lines.

import streamlit as st

st.title("Hello, Streamlit 👋")
st.write("This is your first Streamlit app. It updates in real-time!")

name = st.text_input("Enter your name:")
if name:
    st.success(f"Nice to meet you, {name}!")

▶️ Step 3: Run the App Locally

To launch your app locally, just run:

streamlit run app.py

You’ll see output like this:

  Local URL: http://localhost:8501
  Network URL: http://192.168.0.xxx:8501

Open the local URL in your browser and boom! You’ve got a working app 🎉


🌐 Step 4: Hosting Your Streamlit App

Now that your app works locally, let’s get it online.

✅ Option 1: Deploy for Free on Streamlit Community Cloud

  1. Push your app to a GitHub repository (must include app.py and requirements.txt).
  2. Go to streamlit.io/cloud and sign in with GitHub.
  3. Click “New app” and select your repository.
  4. Fill in the path to your main file (e.g., app.py) and click Deploy.

That’s it! Streamlit will install your dependencies and host your app live.

Example requirements.txt:

streamlit
pandas
matplotlib

📍Your app will be live at https://your-app-name.streamlit.app.


⚙️ Option 2: Self-Hosting on Your Own Server

Prefer full control? You can deploy Streamlit on any server (e.g., a VPS):

  1. SSH into your server.
  2. Install Python, pip, and virtualenv.
  3. Upload your app files.
  4. Install dependencies and run:
streamlit run app.py --server.port 8501 --server.enableCORS false

To keep it running 24/7, use tools like tmux, screen, or systemd.

👉 Optionally, use Nginx + SSL + domain to reverse proxy your app like a pro.


🔐 Bonus Tips

  • You can customize your Streamlit app with themes, layout tweaks, and state handling.
  • Add a secrets.toml file if you need to manage API keys securely on Streamlit Cloud.
  • For analytics or multi-page apps, check out st.experimental_* or use Streamlit Multipage.

📝 Wrapping Up

Streamlit makes it ridiculously easy to go from a Python script to a live app in minutes. Whether you’re showcasing your data project, building an AI demo, or just experimenting—Streamlit helps you focus on the logic, not the UI.

Let’s recap:

  • ✅ Installed and ran a Streamlit app locally
  • ✅ Deployed it for free on Streamlit Cloud
  • ✅ Learned how to self-host it with full control

Got a Streamlit app to show off? Drop the link—I’d love to check it out!
Need help customizing or deploying with Nginx? Just let me know 👇

Happy building! 🧑‍💻

Leave a Reply

Your email address will not be published. Required fields are marked *