#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 and to stick it all together we need to actually create a secret key for our app.
0:10
And this is what it uses to talk to the database and add users, and that data to the database. And we do that in our __init__.py file
0:19
so let's get back to that. All right, and we're just going to chuck it in under here so app.secret_key. Now you can make this whatever you want.
0:35
Obviously this can be as insecure, or as secure as you want but, one of the cool things I've seen done, is import os
0:45
and let's use a function from OS called urandom. So, os.urandom, and this pretty much just generates a series of random bytes
0:57
that are as long as we specify. So let's just use 12. So, os.urandom, 12 bytes long and we are going to get a secret key based on that.
1:09
And that's all we need to be able to create a secret key which Flask is happy to use and then we can run the app.