GET: Seeing Game Status
Learn about the GET method for the Lang-Man application.
Using the GET
method
The next method to define is the GET
method, on the route for the specific game. This one is much simpler. The game_id
from the route is used to query the database for the given game. If it exists, it’s converted to a dict using a custom method for the game ORM class. Otherwise, a 404 error is returned.
The custom conversion to a dict finds all attributes of the object that do not begin with an underscore, and places them into a dictionary. It also computes the game result, which will be one of the following: won, lost, or active. The dates and times must be converted to strings, ...
Access this course and 1400+ top-rated courses and projects.