Deploy the Flask application on Heroku in just 5 minutes

 Deploy Flask Application on Heroku


For small application, you can consider deploying it on any of the following hosted platforms, all of offer free plans for the small application
  • Heroku
  • dotcloud
  • webfaction
Prerequisite:

You must have installed git in you system

Step 1: Install Heroku

    To install Heroku CLI on macOS, first ensure that you have installed Homebrew installed on your machine

brew tap heroku/brew && brew install heroku

If you are using windows or any other system you can click here


Step 2: Create Python virtual environment



Step 3: Install Flask, gunicorn

pip3 install flask gunicorn

Step 4: Create an app folder


Step 5: Create Python app

main.py

Step 6: Create the script to run the web app

run.py



To verify, if the app works, try running this

python run.py

In your browser, go to the IP given and see if it works


Step 7: Make required files to deploy on Heroku

create requirement.txt file

pip freeze > requirements.txt

Create Procfile 

web: gunicorn :app

Step 8: Deploy the app to Heroku

heroku login

Create Heroku app

heroku create <app-name>


Add heroku app to remote




Deploy the flask app to Heroku



And Lastly, push the app to browser



All done, your application should be live

Keep Reading and Happy Coding💜

Comments

Post a Comment

Popular Posts