Chapter 4: HTTP request methods

DELETE request

face Josiah Wang

One more commonly used HTTP method is DELETE. As its name suggests, it is used to delete an existing resource.

Let us try to DELETE our newly created article ID 11 (Apparently, snake puns are no longer popular 😢). The code below should be self-explanatory

>>> response = requests.delete("http://localhost:5000/articles/11")
>>> print(response.json())
{}

As a sanity check that the article has indeed been deleted, we can attempt to retrieve the article with GET.

>>> response = requests.get("http://localhost:5000/articles/11")
>>> print(response.json())
{}

So, our snake pun has officially been deleted! 😢😢😢