#100DaysOfWeb in Python Transcripts
Chapter: Days 17-20: Calling APIs in Flask
Lecture: Environment setup

Login or purchase this course to watch this video and the rest of the course contents.
0:01 So to begin, we are going to set up
0:03 our environment just like we did in our previous Flask work.
0:08 What I am going to do, just to make things
0:10 a little bit simpler, and you're welcome to simply
0:13 copy the code right out of the GitHud repo
0:18 but what I'm going to do here and show you is
0:21 I'm going to actually just copy our entire Flask project
0:26 from day one and we're going to actually extend onto that.
0:30 So all of these API calls that we're going to do
0:33 is going to be within the same Flask app that we created
0:36 at the start of this entire series.
0:38 So let's hop into that first.
0:44 One thing we haven't done here is actually
0:46 created a requirements.txt file so let's do that quickly.
0:55 Okay, and when we do that, that takes all
0:58 of the packages and modules that we've installed
1:01 into this virtual environment here
1:04 dumps it into requirements.txt file
1:07 and then we're able to just simply
1:09 pip-install from that requirements file.
1:14 So we'll deactivate the virtual environment now.
1:18 Head back.
1:20 Let's simply do a recursive copy of this directory.
1:24 We'll delete the virtual environment after we copy
1:27 and created as new just in case.
1:31 Let's create a directory called 2-flaskapicalls.
1:40 Now with that copied, we can hop into it now.
1:45 There's our venv directory, let's delete that.
1:52 Just for good measure, let's also get rid of pycache
1:55 just in case it is referencing anything
1:59 from the previous app.
2:04 All right, do an ls and this is what we're left with.
2:07 That's perfect, we can go into program
2:10 we should have our __init__.py files
2:12 let's get rid of this pycache as well.
2:18 Then we have our templates folder.
2:22 That's everything we wanted, so that's perfect.
2:25 All right, now that we're in this folder
2:27 let's create our virtual environment.
2:32 We'll call that venv, and with that created
2:35 let's activate it again.
2:38 Venv scripts activate, remembering that
2:41 if you are on a Mac or something Unix-based
2:44 you'll have to type in source venv/bin/activate
2:47 and that will get you your virtual environment activated.
2:52 All right, now that that's activated, let's just see
2:55 yes, we have our requirements.txt file.
2:58 We should also have our .flaskenv file
3:02 which we created as well, that was for
3:04 the Flask environment variable, if you remember.
3:08 Let's install all of our packages from requirements.txt
3:14 We do that with pip install minus R requirements.txt
3:24 Of course I have a typo there.
3:28 Let's try that again and there we have it.
3:32 It'll just install all of the packages that we wanted
3:35 Flask_env, python.env, and requests and everything.
3:39 So we'll let that happen and then we can do a pip freeze
3:45 and that will just print it all out for us.
3:47 We have Flask, python.env
3:51 but we don't actually have requests
3:52 and that's because we didn't use requests
3:54 in the last module of introductory Flask
3:58 so let's install that now.
4:00 So pip install requests.
4:09 Now we can actually pipe that into our requirements.txt file
4:15 so let's, just to be sure, pip freeze.
4:27 There we go, and now we are ready to go.
4:30 This is everything we need to get started
4:32 so make sure your environment is set up just like this
4:36 and let's get crackin