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


Talk Python's Mastodon Michael Kennedy's Mastodon