Skip to content
A demonstration of best practices for a large Flask API project
Python
Branch: master
Clone or download
Pull request Compare This branch is 2 commits ahead of apryor6:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
app
commands
.DS_Store
.gitignore
README.md
manage.py
requirements.txt
wsgi.py

README.md

Example Flask API ToDo app.

Using this as a base template for future APIs

  • I edited original repo to just have one route [Widget]

  • Updated requirements.txt to be streamlined [Bring What You Need]

    pip install pytest flask flask_sqlalchemy flask_restplus mypy_extensions marshmallow flask_accepts

  • Updated Widget to just be a ToDo API (CRUD)

  • All tests passing

################### ORIGINAL README ###################

Example of a scalable Flask API

A sample project showing how to build a scalable, maintainable, modular Flask API with a heavy emphasis on testing.

This is an example project using the structure proposed in this blog post.

Running the app

Preferably, first create a virtualenv and activate it, perhaps with the following command:

virtualenv -p python3 venv
source venv/bin/activate

Next, run

pip install -r requirements.txt

to get the dependencies.

Next, initialize the database

python manage.py seed_db

Type "Y" to accept the message (which is just there to prevent you accidentally deleting things -- it's just a local SQLite database)

Finally run the app with

python wsgi.py

Navigate to the posted URL in your terminal to be greeted with Swagger, where you can test out the API.

Running tests

To run the test suite, simply pip install it and run from the root directory like so

pip install pytest
pytest
You can’t perform that action at this time.