Skip to content

Nov 12: Building a Backend

Learning Objectives

After today's class, you should be able to:

  • Implement create, update, and delete endpoints with appropriate status codes.
  • Declare response models, and handle errors such as missing records and constraint violations.

Lesson Outline

Writes and Errors [25 min]

  • Building a Backend
    • Create, read, update, and delete, in HTTP, SQL, and SQLModel
    • Request and response models: one table, several classes
    • exclude_unset, IntegrityError, and where each status code comes from
  • backend_demo.py has every example from the slides, as one program you can run

HW6, Part 2 [30 min]

  • Download the files from HW6, outside your planner clone, and run fastapi dev hw6.py
  • Finish Problems 1–3 if you have not yet, then start Problems 4–8

GP5 Preview [20 min]

  • GP5: your team's endpoints, in router.py
  • With your team: list the endpoints your GP1 use cases need, and decide who writes which

Your To-Do List

  • GP4 responses to your reviewers ← due Friday
  • HW6 ← due Monday