July 2018
Intermediate to advanced
324 pages
8h 14m
English
Let's start the todo API implementation. We need to have a todo REST API endpoint to perform the CRUD operations. As per the REST standard, there would be only one endpoint URL, such as /todos/<todo_id>/. This endpoint will be used to persist the todo data into the database. We will need to have a Todo model to persist the data. The following is the code snippet of the Todo model.
File—todo/models.py:
from datetime import datetimefrom app import dbfrom app.config.models import BaseModelclass Todo(db.Model, BaseModel): __tablename__ = 'todo' id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(128)) is_completed = db.Column(db.Boolean, default=False) created_by = db.Column(db.String(64), db.ForeignKey('user.email')) ...Read now
Unlock full access