Configuring Endpoints
Now that we have defined all our resources, we will set up some endpoints so that users can send requests to them. These endpoints can be accessed by the users and are connected to specific resources. We will be using the add_resource
method on the API object to specify the URL for these endpoints and route the client HTTP request to our resources.
For example, the api.add_resource(RecipeListResource, '/recipes')
syntax is used to link the route (relative URL path) to RecipeListResource
so that HTTP requests will be directed to this resource. Depending on the HTTP verb (for example, GET
, and POST
), the request will be handled by the corresponding methods in the resource accordingly.
Exercise 10: Creating the Main Application File
In this exercise, we will create our app.py
file, which will be our main application file. We will set up Flask and initialize our flask_restful.API
there. Finally, we will set up the endpoints so that users can send...