Quiz
- Is flashing visually displayed like a pop-up in the browser?
No. "Flash" is just the name of the function, not the visual effect.
The effect is up to you. Most of the time, you just display the messages using HTML, though you could make them blink or create
alert
messages in the browser if you wanted.But, yuck.
- How is redirect different from url_for?
They are two different things.
url_for
is used whenever we need to create a URL (endpoint) in our app:- for urls in hyperlinks for the user to click on (the Lookup assignment)
- for action attributes in forms (also the Lookup assignment)
- for urls for static files, like CSS and JS
- for redirects
A redirect is the specific case where our response to the browser is for the browser to make another, different request. (Like when you go to the Bursar and they tell you to go talk to Financial Aid.)
- Are there situations where it's better to use abort() instead of flashing an error message and then redirecting the user?
Rarely. It's good to know about, because it does happen, but I have rarely used abort.
- I'm also just a little confused about the purpose of app.secret_key. What does the secret_key part actually do?
It's used to digitally sign the session, so that it can't be tampered with. This all happens as part of the Flask infrastructure, so it just works.
- Could we go over jinja2 inheritance a little more? / Can you please go over the example of inheritance containing the base template and child templates? / Can we go over inheritance again? Why do we never use head? / Can we go over another example of the jinja inheritance? / Can you please briefly go over template inheritance again? / Could you talk more about template inheritance? Thanks!
We will see a simple example today, and if you want another example, there was one from last time, which we didn't go over.
- Can a child template inherit from multiple parent templates or just one?
Just one.
- I feel like I'm still trying to wrap my head around Jinja 2 but I'm sure I'll get a hang of it with more practise.
I'm sure you will.
- was the cs304 website originally done one page by one page with no template?
God help me, yes. I had learned HTML and CSS, and that makes the content accessible, so I wrote pages. Only later did I learn templating engines. (Other faculty are using Jekyll, which I should learn.)
I also later learned MarkDown, which is helpful as an input to a templating engine.
This is an example of how sometimes it's good to stop investing more time in the current workflow and to back up and try a different way. But there's so much investment, that it's hard to do. It has to be worth it.
I think a lot of the tech industry spends a lot of time/effort/money switching to the latest shiny object.