Best Flask open-source libraries and packages

Flask tdd docker

TDD REST API with Flask, Flask-RESTful, Docker, React (learning project)
Updated 3 years ago

Contributors Issues pipeline status


Logo

Flask TDD Docker

Developing a Flask REST API with Docker, using TDD principles
Explore the docs »

View Demo · Report Bug · Request Feature

Table of Contents

About The Project

The repo represents my learning progress with the testdriven.io course with Flask and Docker.

See a live demo on Heroku.

Built With

  • Flask
  • Flask-RESTful
  • Docker
  • pytest

Getting Started

To get a local copy up and running follow these steps.

Prerequisites

  • Docker 19.03.4
  • docker-compose 1.25.0

Installation

  1. Get the flask-tdd-docker repository
    git clone https://github.com/sophiabrandt/flask-tdd-docker.git
    or, if you have Node.js on your machine:
    npx degit https://github.com/sophiabrandt/flask-tdd-docker.git flask-tdd-docker
  2. Build docker containers
    docker-compose build
  3. Run docker containers
    docker-compose up -d

Usage

  • Run tests:

    docker-compose exec users pytest "project/tests" -p no:warnings
  • Run test coverage:

    docker-compose exec users pytest "project/tests" -p no:warnings --cov="project"
  • Recreate database:

    docker-compose exec users python manage.py recreate_db
  • Seed database:

    docker-compose exec users python manage.py seed_db
  • Run flake8, black, isort:

    docker-compose exec users flake8 project
    docker-compose exec users black project
    docker-compose exec users /bin/sh -c "isort project/*/*.py"
  • Query all users:

    curl http://localhost:5001/users
    curl https://desolate-cliffs-02122.herokuapp.com/users
  • Query specific user (by id):

    curl http://localhost:5001/users/1
    curl https://desolate-cliffs-02122.herokuapp.com/users/1
  • Create new user:

    curl -d '{"username":"jane","email":"jane@test.cc"}' -H "Content-Type: application/json" -X POST http://localhost:5001/users
    curl -d '{"username":"jane","email":"jane@test.cc"}' -H "Content-Type: application/json" -X POST https://desolate-cliffs-02122.herokuapp.com/users
    
  • Update a user:

    curl -d '{"username":"jane","email":"jane@test.cc"}' -H "Content-Type: application/json" -X PUT http://localhost:5001/users/1
    curl -d '{"username":"jane","email":"jane@test.cc"}' -H "Content-Type: application/json" -X PUT https://desolate-cliffs-02122.herokuapp.com/users/1
  • Delete a user:

    curl -X DELETE http://localhost:5001/users/1
    curl -X DELETE https://desolate-cliffs-02122.herokuapp.com/users/1

Roadmap

See the open issues for a list of proposed features (and known issues).

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Please note that this is a learning repository, not a real project.
As the code is not mine, I can't give it an open-source license.

License

Code is © Michael Herman 2019, with minor modifications by Sophia Brandt.

Contact

Sophia Brandt - @hisophiabrandt

Project Link: https://github.com/sophiabrandt/flask-tdd-docker

Acknowledgements