#100DaysOfWeb in Python Transcripts
Chapter: Days 57-60: Flask Login
Lecture: Let's start by setting some expectations

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


Talk Python's Mastodon Michael Kennedy's Mastodon