Frameworks such as Flask, FastAPI and Django handle sockets and parsing, but the decisions that make an API correct are yours: which status code a request gets, what a valid body looks like, what happens when a client retries, and where a list ends.
These tasks build those decisions as plain functions, which is also how they are best tested. You route requests to 200, 201, 204, 404 and 405, validate a JSON body and report every problem at once, replay a create safely when the same idempotency key comes back, and page through a list without off-by-one errors.
The last task turns it around. You write contract checks for a router and prove them on deliberately broken versions: a test suite is only as good as the bugs it catches. Nothing here opens a network port; each handler is called directly.
Out: (['orders', '42'], True). Path segments decide 404 before the method decides 405.