Class 10 Prep Review
Here are some review questions for you to solidify your knowledge of the concepts covered in this class:
-
What is the special value that will be assigned to
userif the query didn't find a matching user in this statement:user = User.query.filter_by(email=email).first() -
What is a
session? Why do we use it? What data type is Flask'ssessionobject? -
What is the decorator
@app.before_requestused for? When is a function with that decorator called? Explain what is going on in this code snippet:@app.before_request def require_login(): allowed_routes = ['login', 'register'] if request.endpoint not in allowed_routes and 'email' not in session: return redirect('/login') -
Why are flash messages useful? How do they relate to the session object?
-
Describe what this line in the
Userclass means:tasks = db.relationship('Task', backref='owner')