Eve: Building RESTful APIs with MongoDB and Flask Transcripts
Chapter: Your first Eve service
Lecture: Connecting to Mongo

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Our small app is now capable of responding to get request sent to the people endpoint. But when a client performs a request like that,
0:10 or it gets back as an empty array, and some metadata, so how do we send data back to the client? Well, the first thing we want to do probably is
0:20 connect our app to an actual database because so far, we haven't done that yet. So let's go back to our code editor, and in the settings file,
0:31 we want to add a new keyword, and not surprisingly, it's going to be mongo uri. And this is going to be the connection string to our db
0:41 so mongo db-- local host, here we go, so this is a standard Mongo uri, where we are connecting to the Mongo running on local host on port 2017
0:58 and db name is going to be Eve course. Save, of course, your file and you also have to relaunch your app
1:07 because the settings file is imported at startup time and then if you change it, now it changes the Eve 01:21 if you are running Flask in debug mode,
1:17 so when you make a change to the settings file, you also have to remember to relaunch your app. Let's go back to our client,
1:27 and just to make sure that everything is working fine, perform our request, and yes, everything is fine, and we are still getting an empty array
1:35 because we don't have any data on the database, even if it is connected, there is no data store in there.
1:40 So I guess it's time to start writing on our db.


Talk Python's Mastodon Michael Kennedy's Mastodon