[MUSIC]
0:00
Hi, my name is Megan, and
I'm a teacher here at Treehouse.
0:09
My pronouns are she/her/hers.
0:13
In this course, I'll teach you how to work
with Flask, a popular Python framework for
0:16
creating websites or web applications.
0:21
A framework is a collection of code
that makes building something easier.
0:25
Flask will help us to create a website.
0:30
Because it has written
a lot of the code for us,
0:33
we just need to learn how
to use these new tools.
0:36
Flask helps us work with
the request response cycle.
0:40
Let's take a look at what that means.
0:44
The application gets requests, which
are people on the internet asking for
0:47
information from our application.
0:52
Once they get to our application,
it looks at all the routes available,
0:55
and figures out which function to call.
1:00
A lot of people call these
functions controllers, but
1:03
they can also be called views.
1:07
The view then sends back a response,
which can be HTML, or JSON, or XML.
1:09
A user requests information
from your site.
1:16
Your site determines how to handle the
request and what information to send back.
1:20
And then a response is sent to the user.
1:25
So when a user asks for
Treehouse's homepage,
1:28
the site will receive the request and
send back the home page's information.
1:32
Together, we're going to create this
pet adoption website using Flask,
1:38
SQLAlchemy, HTML, and CSS.
1:44
It will hold a list of pets available for
adoptions.
1:46
Users will also have the ability to add,
1:50
Edit, and delete.
2:04
As we go along, feel free to play
around with the site's colors and
2:08
structure to make it your own.
2:12
For this project,
you can follow along in workspaces.
2:15
It already has Flask installed, and
2:18
I have attached them to
the videos moving forward.
2:20
If you would like to follow along locally,
you will need to install Flask.
2:24
I would also suggest creating
a virtual environment to
2:28
practice a typical workflow.
2:31
First, I created a new project folder
called adoption-flask-project,
2:34
and I opened it inside of my IDE.
2:39
I'm using Visual Studio, but
please use whichever IDE or
2:41
integrated development environment
you feel comfortable with.
2:45
You can find links to two
favorites in the teacher's notes.
2:49
Once I opened it,
I can navigate to the terminal and
2:53
create a virtual environment by
running python3 -m venv env.
2:59
On a Windows computer, you may not
need this 3 here at the end of python.
3:08
I'm on a Mac, so I am going to use it.
3:12
You can see it created my environment
folder, and Visual Studio's like, hey,
3:18
you created a virtual environment,
do you wanna use it?
3:22
And yes we do, we
definitely wanna use it. Awesome,
3:25
now I need to activate the environment
3:31
by running, on Windows,
3:37
you would do .\env\Scripts\activate.
3:41
If you're on a Mac, like I am,
then you do source and
3:49
then you do forward slashes as opposed
to backslashes, ./env/bin/activate.
3:54
So make sure to use the one that works for
your machine.
4:01
They're also listed in
the teacher's notes, just in case.
4:03
So I'm gonna go ahead and do that.
4:07
And you can see it's activated now
because I have this environment here at
4:08
the beginning of my command prompt.
4:13
Okay, so
now we have our environment activated,
4:15
let's install Flask,
we'll use pip install flask.
4:20
Awesome, and
to make sure that it got installed,
4:26
we can do pip freeze > requirements.txt.
4:34
Hit Enter, and it'll create that
requirements.txt file here.
4:40
And you can see everything that
gets downloaded along with Flask.
4:44
Perfect, now that our project requirements
file is ready, if you want to create
4:50
a repo for this project, and others end up
wanting to run your project to check it
4:55
out, all they'll have to do is download
the requirements from this file.
5:00
If you do wanna post this on GitHub,
then let's also create a gitignore file.
5:05
Do new file, .gitignore, and then inside,
5:11
we don't want this env file to be sent up,
so I'm gonna do env.
5:15
VS Code also creates this folder,
we don't need that either.
5:21
And another good one is /__pycache__,
5:26
you might have seen it already
when working with Python.
5:29
It's a file that gets created sometimes,
and we don't need that either.
5:34
And if you're on a Mac,
5:38
there's also this .DS_Store file
that pops up from time to time.
5:39
And it's specific to Macs,
so if you're on a Windows,
5:44
you don't need to worry about that one,
but it's always a good one to ignore.
5:47
Cool, make sure you save, and then we
don't need that file anymore right now,
5:51
and you're all set to
work on this locally.
5:55
I also posted these steps in the teacher's
notes below for reference, along
5:58
with a resource on virtual environments in
case you decide to work locally later on.
6:02
Again, choose the path that works best for
you.
6:09
I'll have the resources available
throughout the course for
6:12
both local and workspaces-based projects.
6:16
I'm excited to work on this project
with you, so let's get started.
6:19