-
Book Overview & Buying
-
Table Of Contents
Flask Framework Cookbook
By :
As the name suggests, REpresentational State Transfer (REST) calls for segregating your API into logical resources, which can be accessed and manipulated using HTTP requests, where each request consists of a method out of GET, POST, PUT, PATCH, and DELETE (there can be more, but these are the ones used the most). Each of these methods has a specific meaning. One of the key implied principles of REST is that the logical grouping of resources should be easily understandable and, hence, provide simplicity along with portability.
Up until now in this book, we have used a resource called Product. Let's see how we can logically map our API calls to the resource segregation:
GET /products/1: This gets the product with ID 1
GET /products: This gets the list of products
POST /products: This creates a new product
PUT /products/1: This updates the product with ID 1
PATCH /products/1: This partially updates the product with ID 1
DELETE /products/1: This deletes the product with ID 1
Change the font size
Change margin width
Change background colour