#100DaysOfCode in Python Transcripts
Chapter: Days 97-99: Building JSON APIs
Lecture: Implementing the create-game method

Login or purchase this course to watch this video and the rest of the course contents.
0:00 How's our create game operation working, here we're going to do a post of this. This says we would create a new game.
0:08 If you think about how the way that our data base actually works, there's not actually a lot of integrity around this game concept and
0:15 we maybe could create some more models and put them in there but one of my goals of this is to change as little as possible
0:21 about the models and data access layer and the other stuff we've already done and just to adapt it to online.
0:27 Not exactly possible but it is very, very close. What we really need to do here is to just create a unique id that can be shared.
0:36 Okay? And it turns out we can do that super easily. So we're going to create a dictionary. In our dictionary we're going to have a game id
0:47 and how do we get it it? It's going to be a UUID, which is a standard library thing we got to import at the top and there's UUID4,
0:54 which is a great random thing we could use but we're just going to create a string representation of it and give that back. Let's save this,
1:02 it should reload if everything worked out. Instead of saying "would create a game" what do we get? Boom. There is a very unique looking game id
1:10 that we can then use for all subsequent requests to correlate or relate the various operations between say playing around, getting the game status,
1:18 things like that. So that's it. Create a game, just create a random identifier that we can use that is pretty unique.

Talk Python's Mastodon Michael Kennedy's Mastodon