Loading repository data…
Loading repository data…
edonosotti / repository
A sample Python app that implements a REST API, with database migrations and CI/CD support.
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
NOTE: This code was written for an article in the RockedScience publication on Medium.
This sample Python REST API application was written for a tutorial on implementing Continuous Integration and Delivery pipelines.
It demonstrates how to:
Also:
Python 3.8Pipvirtualenv, or conda, or minicondaThe psycopg2 package does require libpq-dev and gcc.
To install them (with apt), run:
$ sudo apt-get install libpq-dev gcc
With virtualenv:
$ python -m venv venv
$ source venv/bin/activate
$ pip install -r requirements.txt
With conda or miniconda:
$ conda env create -n ci-cd-tutorial-sample-app python=3.8
$ source activate ci-cd-tutorial-sample-app
$ pip install -r requirements.txt
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 seed.py
Run:
$ python -m unittest discover
Run the application using the built-in Flask server:
$ flask run
Run the application using gunicorn:
$ pip install -r requirements-server.txt
$ gunicorn app:app
To set the listening address and port, run:
$ gunicorn app:app -b 0.0.0.0:8000
Run:
$ docker build -t ci-cd-tutorial-sample-app:latest .
$ docker run -d -p 8000:8000 ci-cd-tutorial-sample-app:latest
Run:
$ heroku create
$ git push heroku master
$ heroku run flask db upgrade
$ heroku run python seed.py
$ heroku open
or use the automated deploy feature:
For more information about using Python on Heroku, see these Dev Center articles: