CD/CI Tutorial Sample App

by edonosotti


Build Status codebeat badge Maintainability

CD/CI Tutorial Sample Application


This sample Python REST API application was written for a tutorial on implementing Continuous Integration and Delivery pipelines.

It demonstrates how to:

  • Write a basic REST API using the Flask microframework
  • Basic database operations and migrations using the Flask wrappers around Alembic and SQLAlchemy
  • Write automated unit tests with unittest


  • Python 3.6
  • pip
  • virtualenv



$ pip install -r requirements.txt
$ python -m venv venv
$ source venv/bin/activate

Optional: set the DATABASE_URL environment variable to a valid SQLAlchemy connection string. Otherwise, a local SQLite database will be created.

Initalize and seed the database:

$ flask db upgrade
$ python

Running tests


$ python -m unittest discover

Running the application

Running locally

Run the application using the built-in Flask server:

$ flask run

Running on a production server

Run the application using gunicorn:

$ gunicorn app:app

Deploying to Heroku


$ heroku create
$ git push heroku master
$ heroku run flask db upgrade
$ heroku run python
$ heroku open

or use the automated deploy feature:


For more information about using Python on Heroku, see these Dev Center articles: