Code Monkey home page Code Monkey logo

todo-list-python's Introduction

TODO List in Python

Build Status

Custom image

What is this?

TO DO List is a simple API project created with everything that I learned on course Do Zero ao Deploy by Cássio Botaro.

This project covers the following concepts:

  • Python environments with Pipenv
  • Test Driven Development with PyTest
  • Starting with Flask framework
  • Continuous Integration with Travis
  • Continuous Deployment with Heroku

Starting from what has been taught, I improved the API with MongoDB persistence.

Environment

API

All code was written with Python 3.6, so, for a correct running, it is recommended to install this one.

After Python installed, it is required to install all dependencies. You can use Pipenv or Virtualenv. If you are using Pipenv, use the following command to install from Pipfile:

$ pipenv install

...and active the environment:

$ pipenv shell

However, if you are using Virtualenv, you need to activate the environment and install from requirements.pip file:

$ source YOUR_ENVIRONMENT_DIRECTORY/bin/activate
$ pip install -r requirements.pip

Database

Install MongoDB in your machine and be sure MongoDB process is running.

How to run

$ python todo.py
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

API Endpoints:

  • GET /tasks: Return all tasks available
  • POST /tasks: Create a new task

Testing (Optional)

You can test the application using the development dependencies.

Install all development dependencies from Pipfile:

$ pipenv install --dev

Or from dev-requirements.pip file if you are using VirtualEnv:

$ pip install -r dev-requirements.pip

To debug endpoints, you can use HTTPie as following:

$ http http://127.0.0.1:5000/tasks
[
  {
    "_id": {
      "$oid": "5ad3d924e3bdea6ccf9d9d3e"
    },
    "description": "The Best Description",
    "done": false,
    "title": "The Best Title"
  },
  {
    "_id": {
      "$oid": "5ad3d8fae3bdea6c41d571f4"
    },
    "description": "The Incredible Description",
    "done": false,
    "title": "The Incredible Title"
  }
]
$ http POST http://127.0.0.1:5000/tasks title=Test description=Test
HTTP/1.0 201 CREATED
Content-Length: 123
Content-Type: application/json
Date: Mon, 16 Apr 2018 00:23:45 GMT
Server: Werkzeug/0.14.1 Python/3.6.2

{
  "_id": {
    "$oid": "5ad3ed11e3bdea06aa7afa06"
  },
  "description": "Test",
  "done": false,
  "title": "Test"
}

To run the tests, you can use PyTest as following:

$ python -m pytest
...
collected 7 items

test_todo.py .......                                                    [100%]
========================== 7 passed in 1.32 seconds ==========================

todo-list-python's People

Contributors

marcosvbras avatar mcgavin20 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.