Deploying Your Python App on Heroku in Minutes

Building a Python app is exciting—but sharing it with the world is even better. Heroku is a beginner-friendly platform that lets you deploy your Python web apps in just a few minutes. This guide will walk you through the step-by-step process to get your project online fast.


Why Deploy on Heroku?

  • Easy setup with Git
  • Free tier available for small projects
  • Supports Python, Flask, Django, and more
  • Great for showcasing projects and prototypes

Prerequisites

Before you begin, make sure you have:

  • A working Python web app (e.g., built with Flask or Django)
  • Python installed on your system
  • Git installed
  • A free Heroku account

Step 1: Prepare Your App

For Flask apps, make sure your main file looks something like this:

python

Copy code

from flask import Flask

app = Flask(__name__)

@app.route(“/”)

def home():

    return “Hello, Heroku!”

if __name__ == “__main__”:

    app.run()


Step 2: Create Required Files

requirements.txt

bash

Copy code

pip freeze > requirements.txt

Procfile

Create a file named Procfile (no extension) with this line:

makefile

Copy code

web: python app.py

✅ Replace app.py with your actual entry file name.


Step 3: Initialize Git and Commit

bash

Copy code

git init

git add .

git commit -m “Initial commit”


Step 4: Deploy to Heroku

  1. Login to Heroku:

bash

Copy code

heroku login

  1. Create a Heroku App:

bash

Copy code

heroku create your-app-name

  1. Push Your Code:

bash

Copy code

git push heroku master

  1. Open in Browser:

bash

Copy code

heroku open

Your app should now be live!


Troubleshooting Tips

  • Make sure your requirements.txt includes gunicorn if needed for production
  • Use heroku logs –tail to view real-time logs
  • Use heroku ps:scale web=1 if the dyno is sleeping

Practice Tip

Try deploying a simple to-do app, chatbot, or portfolio site. Heroku makes it easy to test real-world deployment scenarios—even as a beginner.


Grow Beyond Localhost

Learning to deploy apps is a game changer. It transforms your projects from local experiments into public demos or production tools.

🚀 Ready to learn full-stack development and deploy real apps?
👉 https://www.thefullstack.co.in/courses/

You might be like this:-

Python Modules and Packages

What is AWS Lambda?A Beginner’s Guide to Serverless Computing in 2025

Java vs. Kotlin: Which One Should You Learn for Backend Development?

Where to Find Your Salesforce Organization ID

admin
admin
https://www.thefullstack.co.in

Leave a Reply