#100DaysOfWeb in Python Transcripts
Chapter: Days 57-60: Flask Login
Lecture: Specify the app secret key

Login or purchase this course to watch this video and the rest of the course contents.
0:00 In order for any of this to actually work
0:02 and to stick it all together
0:04 we need to actually create a secret key for our app.
0:09 And this is what it uses to talk to the database
0:11 and add users, and that data to the database.
0:15 And we do that in our __init__.py file
0:18 so let's get back to that.
0:24 All right, and we're just going to chuck it in under here
0:28 so app.secret_key.
0:32 Now you can make this whatever you want.
0:34 Obviously this can be as insecure, or as secure as you want
0:39 but, one of the cool things I've seen done, is import os
0:44 and let's use a function from OS called urandom.
0:48 So, os.urandom, and this pretty much
0:51 just generates a series of random bytes
0:56 that are as long as we specify.
0:58 So let's just use 12.
1:00 So, os.urandom, 12 bytes long
1:04 and we are going to get a secret key based on that.
1:08 And that's all we need to be able to create a secret key
1:11 which Flask is happy to use
1:13 and then we can run the app.