/sample-python-api

A Sample Python API with Pipenv, Flask, Flask RESTPlus, and PyTest

Primary LanguagePython

Overview

This is a simple Python API boilderplate using Flask and Flask-RESTPlus. It uses Pyenv and Pipenv for runtime and package management. It also uses pytest and pytest-flask for unit testing.

You can find detailed documentation on this boilerplate's set-up here.

Set Up

Install Pyenv following the official installation instructions.

Download the proper python version:

# Installs the version from ".python-version" if not installed 
# Can take some time.
pyenv install

Install pipenv:

pip install --user pipenv

Install all dependencies

pipenv install

Run locally

# If you haven't already, then start a pipenv shell
pipenv shell

PYTHON_ENV=development python src/main.py

Visit Swagger UI on http://localhost:5000/api/swagger.

Run unit tests

# If you haven't already, then start a pipenv shell
pipenv shell

python -m pytest