Deploy the Flask application on Heroku in just 5 minutes
Deploy Flask Application on Heroku
- 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
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💜
Thank you so much👍🏻
ReplyDelete