Skip to content

StevieWag/flask-heroku-example

 
 

Repository files navigation

Flask Heroku Example

(This repo is part of our Free Flask Tutorial)

This repo contains some sample code to deploy a simple (but complete) Flask application to Heroku. The deployed app counts with the following features:

  • Running Python 3.6 🐍
  • Access to a Postgres Database 📘
  • Static Files management with WhiteNoise 🔌

There's a detailed video lesson on how to perform the deploy in our Free Flask Tutorial.

Summary of steps to deploy your app

(Assuming you've already created an account with Heroku)

1. Clone the repo
$ git clone https://github.com/rmotr-curriculum/flask-heroku-example.git && cd flask-heroku-example
2. Login to Heroku
$ heroku login
3. Create your Heroku apps
$ heroku create
4. Set the Python Path
$ heroku config:set PYTHONPATH=flask_heroku_example
5. Add Postgres Add-on to your Heroku app

(Use Heroku's site to add Postgres. It's free)

6. Initialize the Database
$ # Create the initial schema
$ heroku pg:psql < schema.sql
$ # Load some initial testing data
$ heroku pg:psql < initial_data.sql
7. Deploy & Profit
$ git push heroku master

Running the app locally

(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 flask-heroku-example
# Install dependencies
$ pip install -r requirements.txt
# Run the app
$ python flask_heroku_example/main.py
# Now point your browser to localhost:5000

About

Deploy your Flask app to Heroku. Check our Free Flask tutorial: https://flask-tutorial.com

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HTML 54.4%
  • Python 44.8%
  • CSS 0.8%