6 Simple Steps to Deploy NLP based Flask Application on Heroku

Image 1: NLP Application hosted on Heroku Server

1. Objective

2. Assumption

Image 2: Flask application on local system
Image 3: System specification

3. Step by Step process

Image 4: Creating account on heroku
Image 5: Account Activation Mail from Heroku
Image 6: Successful Log In to Heroku
sudo apt install snapd
sudo snap install --classic heroku
Image 7: Heroku Installation
heroku login -i
## If you get issue, heroku: command not found, Follow below commands
sudo vi /etc/environment
## If you not able to find :/snap/bin in /etc/environment file, add it, save;close;execute below command and finally should look like Image 8
## Saving and activate environment
source /etc/environment && export PATH
Image 8: Setting up environment for Heroku
## Again try for heroku login via CLI
heroku login -i
## If it asks for login credentials (Image 9), it means heroku CLI installation is successful
Image 9: Heroku Login via CLI successful
## Current working directory in terminal should be root directory of flask application
source /etc/environment && export PATH
## create application with app name: "aakash-word-booster" - Image 10heroku create aakash-word-booster
Image 10: Application creation
web: gunicorn api:app
gunicorn==19.10.0
flask==0.12
nltk==3.3
wordnet 
## Initialization of git
git init
## attaching git to heroku application name - Image 11
heroku git:remote -a aakash-word-booster
## Use below command to validate above attaching command, it should display exactly - Image 12
git remote -v
## git adding complete flask application to it
git add .
## commit your flask application - Image 13
git commit -m "first heroku commit"
## Push your application to heroku - Image 14
git push heroku master
Image 11: Attacing git to heroku application
Image 12: Validation of git attach to heroku
Image 13: Output after git commit
Image 14: Output after git push

4. References

Hurray !! You learned how to deploy NLP based Flask Application on Heroku.

Senior Data Scientist @ Fractal Analytics