The following table shows the function that we want to be executed for each combination of HTTP verb and scope, and the route name that identifies each resource:
HTTP verb |
Scope |
Route name |
Function |
GET |
Collection of metrics |
'metrics' |
metrics_collection |
GET |
Metric |
'metric' |
metric |
POST |
Collection of metrics |
'metrics' |
metrics_collection |
DELETE |
Metric |
'metrics' |
metric |
We must make the necessary resource routing configurations to call the appropriate functions, pass them all the necessary arguments by defining the appropriate routes, and match the appropriate view callable with the route.
First, we will check how the application template we used configures and returns a Pyramid WSGI application that will run our RESTful API. The following lines...