Python - Flask

Revision as of 08:03, 22 September 2020 by Rasimsen (talk | contribs) (The RESTful server)

Rest APIs Development with Flask-RESTful

Flask extension that simplifies the creation of APIs.

The RESTful server

Here is the definition of the ToDo List web service that has been serving as an example:

HTTP Method  URI                                                Action
GET          http://[hostname]/todo/api/v1.0/tasks              Retrieve list of tasks
GET          http://[hostname]/todo/api/v1.0/tasks/[task_id]    Retrieve a task
POST         http://[hostname]/todo/api/v1.0/tasks              Create a new task
PUT          http://[hostname]/todo/api/v1.0/tasks/[task_id]    Update an existing task
DELETE       http://[hostname]/todo/api/v1.0/tasks/[task_id]    Delete a task

The only resource exposed by this service is a "task", which has the following data fields:

  • uri: unique URI for the task. String type.
  • title: short task description. String type.
  • description: long task description. Text type.
  • done: task completion state. Boolean type.