#100DaysOfWeb in Python Transcripts
Chapter: Days 57-60: Flask Login
Lecture: Let's start by setting some expectations
0:00 We're going to look at the
0:01 app structure now over the next few days.
0:04 There's quite a bit of prep that you have to do
0:06 to get to the ability to log in to your Flask app.
0:10 So I wanted to run through that really quickly now
0:13 and just set that expectation of what I'm going to include
0:16 and what we're going to exclude from this course
0:19 for these four days.
0:21 So the first thing we are going to do
0:23 is have our base Flask application code.
0:27 What you'll notice straight away is that this
0:29 is going to be pretty bare bones.
0:31 We're not using the same apps that we've created so far.
0:35 We're not going to touch on the Pokemon API
0:37 or the Chuck Norris API or any of that similar app.
0:40 We're actually going to chop out all of that complicated stuff
0:44 and get us right back to the bare bones
0:47 of just simple text on a website.
0:49 Then, we're going to go through creating
0:52 a user model for use in the database.
0:55 Now this is half of the whole SQLAlchemy method
0:59 that we're going to use for our database.
1:01 And the first part of that is to create a model
1:05 that SQLAlchemy then uses to create our database.
1:08 I'll get into that a little bit later.
1:11 Then, once we've actually taken that model
1:14 we create the database.
1:16 And in our case, this is going to be a database
1:19 of users who access our website.
1:22 Obviously we need that because if you're going to log in
1:25 you need to have users that are allowed and what-not.
1:28 Then, we actually have to create some users
1:31 and I was thinking, you know, we could just put dummy users
1:35 into the database, but that's not really applicable
1:37 to real life, right?
1:38 And that's what we're all about here.
1:40 This is all usable stuff.
1:41 So we're going to create a page on our website
1:45 a template where people can browse to it.
1:48 They don't have to be logged in to do it, obviously.
1:51 And they can then create users and a password.
1:55 Once they've done that
1:56 it's stored in this SQLAlchemy database.
2:00 And then, we can finally move on to
2:03 the actual Flask login component.
2:05 And this is where we can then access the SQLAlchemy database
2:09 and we can pull on that data to see if the person
2:13 trying to log in is allowed to, as in
2:17 do they exist in the database or not.
2:20 Okay, and that's as simple as we're going to go.
2:22 We're not going to go much more advanced than that, if at all.
2:26 We're going to stick to that core concept
2:28 does a user exist in the database?
2:30 If they do, they can access the website.
2:33 All of that wrapped in Flask login.
2:36 Okay, we are not using the non-Flask login method.
2:40 I know it is out there
2:41 you've probably Googled it and seen it before.
2:43 We're going to use specifically Flask login for this.
2:46 And that's pretty much it.
2:48 One other thing I'll touch on really quickly here
2:51 is I am not hashing passwords.
2:54 Now, I know that's important.
2:55 I know that's something you will have to do.
2:57 But in the interest of keeping this simple
3:01 keeping it within the couple of days that we have
3:03 to do this, we are actually going to leave that out.
3:06 And that's because that is a really quick Google search
3:08 and something you can actually figure out
3:10 in one of your days if you have the time.
3:12 Just keep in mind we have a limited time here.
3:15 I'm respecting your time, so this is how we're going to do it.
3:18 So, let's move on, get some application code together
3:22 and then start on the database.