How to deploy Flask to Heroku
- Running Python 3.6 🐍
- Access to a Postgres Database 📘
- Static Files management with WhiteNoise 🔌
(Assuming you've already created an account with Heroku)
$ git clone *Cloned Repo && cd *Nme of repo
$ heroku login
$ heroku create
$ heroku config:set PYTHONPATH=flask_heroku_example
(Use Heroku's site to add Postgres. It's free)
$ # Create the initial schema
$ heroku pg:psql < schema.sql
$ # Load some initial testing data
$ heroku pg:psql < initial_data.sql
$ git push heroku master
(You need to have installed Postgres locally to run the app. For a simpler sqlite alternative, please check the aforementioned tutorial)
# Create the virtualenv
$ mkvirtualenv *repo
# Install dependencies
$ pip install -r requirements.txt
# Run the app
$ python *repo/main.py
# Now point your browser to localhost:5000