1. What makes it RESTful
Each kind of data is a resource with its own URL, here /api/assignments, and the HTTP method says what to do with it: GET to read, POST to create, PUT or PATCH to update and DELETE to remove.
2. The parts that earn marks
- Database access: setting
row_factory = sqlite3.Rowlets each row be turned into a dictionary, whichjsonifycan send straight back. - Checking input first: the POST route rejects a request without a title or subject before it reaches the database, so bad input gets a clear
400instead of a server error. - Meaningful status codes:
200for a successful read,201 Createdfor a new record and400 Bad Requestfor invalid data. - Safe SQL: the
?placeholders pass values separately from the query, which prevents SQL injection.
3. Adding update and delete
Add routes on /api/assignments/<int:assignment_id>: PUT runs an UPDATE and DELETE runs a DELETE, and both return 404 when cursor.rowcount is 0 because no record had that id.