Skip to content

MashSoftware/flask-rest-api

Repository files navigation

Flask REST API Template

This template repository contains a Flask app based RESTful API. The app is structured based on best practices and experience gained through previous implementations. By using a template repository you can generate a new repository with the same directory structure and files to get a new project started quicker.

Prerequisites

Required

  • Python 3.7.x or higher
  • PostgreSQL 11.x or higher

Optional

  • Redis 4.0.x or higher (for rate limiting, otherwise in-memory storage is used)

Getting started

Create local Postgres database

sudo service postgresql start
sudo -su postgres
psql
create user mash with password 'mash';
createdb thing;
grant all privileges on database thing to mash;

Create venv and install requirements

python3 -m venv venv
source venv/bin/activate
pip3 install -r requirements.txt ; pip3 install -r requirements_dev.txt

Run database migrations

flask db upgrade

Run app

flask run

Testing

Run the test suite

python -m pytest --cov=app --cov-report=term-missing --cov-branch