Parameters
At this stage, you should have a well-structured base project and a database configured with a table to keep blog post records.
Before writing code, it's worth understanding the difference between Path Parameters and Query Parameters.
Path Parameters
Path parameters are parameters that get included in the context path of a URL. For example, the unique ID of each blog post gets appended to the URL providing a link to individual posts.
So a corresponding function would be matched, and can utilize the value 963e4ca9-2080-4f15-93ba-a8509bb63f6b
which becomes id
from {id}
, for example:
Query Parameters
A query a parameter is a key/value pair appended to a URL after a ?
, for example:
So the corresponding function doesn't have any defined {}
parameter in the path, but the function does expect an incoming value, in this case limit
. (The syntax | None = None
is new since Python 3.10):
Keep this in mind when working through the upcoming CRUD examples.