Mรณdulo 06 ยท Flask Deeper โ Lecciรณn 2 de 4 ยท ~9 min
POST & validation by hand
Reading a POST body
GET /walkers?min_rating=4.8 puts data in the URL. Creating something โ like a booking โ needs more data than fits comfortably in a URL, so it travels in the request body as JSON. Flask reads it with request.get_json(), which does the json.loads from module 17 for you and hands back a plain Python dict โ or None if the body wasn't valid JSON at all.
PawWalk's real backend defines a booking's shape in app/schemas.py: a walker_id, and a duration that must be one of Duration = Literal[30, 45, 60] โ never any other number of minutes. Flask has never heard of Literal. Every one of those rules is now your job, checked by hand, one if at a time.