Implement the DELETE Endpoint for Removing an Existing Product

Learn how to implement the products API using Flask to delete an existing product.

The equivalent of the Delete CRUD operation in REST is the DELETE method. It can be used in REST API to indicate that a particular resource in a collection needs to be removed or marked as not processable. If one looks at the URI for DELETE, it will look the same as that for GET. Hence, from a URI perspective, DELETE and GET use the same template.

In Flask, the path parameter of the URI gets mapped to the parameter of the method. The product ID passed as the path parameter can be used to delete the corresponding product from the list. In this section, let’s see how to provide a DELETE REST endpoint.

Get hands-on with 1200+ tech skills courses.