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
0:03 to get request sent to the people endpoint.
0:06 But when a client performs a request like that,
0:09 or it gets back as an empty array, and some metadata,
0:13 so how do we send data back to the client?
0:16 Well, the first thing we want to do probably is
0:19 connect our app to an actual database
0:22 because so far, we haven't done that yet.
0:26 So let's go back to our code editor, and in the settings file,
0:30 we want to add a new keyword,
0:32 and not surprisingly, it's going to be mongo uri.
0:36 And this is going to be the connection string to our db
0:40 so mongo db-- local host, here we go,
0:49 so this is a standard Mongo uri,
0:52 where we are connecting to the Mongo running on local host on port 2017
0:57 and db name is going to be Eve course.
1:01 Save, of course, your file and you also have to relaunch your app
1:06 because the settings file is imported at startup time
1:10 and then if you change it, now it changes the Eve 01:21
1:13 if you are running Flask in debug mode,
1:16 so when you make a change to the settings file,
1:19 you also have to remember to relaunch your app.
1:24 Let's go back to our client,
1:26 and just to make sure that everything is working fine,
1:28 perform our request, and yes, everything is fine,
1:32 and we are still getting an empty array
1:34 because we don't have any data on the database,
1:36 even if it is connected, there is no data store in there.
1:39 So I guess it's time to start writing on our db.