Making HTTP Requests to the Flask API using curl and httpie
Now, we are going to use the httpie
and curl
commands to test our API endpoints. We will test the functions for getting all the recipes back from the server and create/update/delete, publish, and unpublish the recipes. The best way to learn this is to complete a hands-on exercise. Let's get started!
Exercise 11: Testing the Endpoints Using curl and httpie
In this exercise, we are going to use the httpie and curl commands to send requests to the endpoints so that we can create our first recipe. We want you to get comfortable using the httpie and curl command-line testing tool. Let's get started:
- Open the Terminal in PyCharm and type in the following commands. You can use either the httpie or curl command. The following is the httpie command (
= is for string and := is for non-string
):http POST localhost:5000/recipes name="Cheese Pizza" description="This is a lovely cheese pizza" num_of_servings...