Quiz

  1. Can you explain a bit about where the information goes after a form is submitted and where that data can be accessed?

    Yes, that's a common one. I just added something to the lecture notes

  2. Can you review the templating in more detail? How do you add content to a page? Is templating just for the structure of the page? How do you add content to a template?

    Sure. Templating puts some of your text in a file. The static parts. If you want to add content dynamically, you have to render more data to the template, and the template has to be ready for it. You could always do:

    
    <div> {{ miscellaneous }} </div>
    
    

    and render anything you want in your template.

    Templating is mostly for structure and for "boilerplate" content, like logos, copyrights, etc. Stuff that you want on every page but is not dynamic.

    To add content to a template, you have to edit the file. Because it's static.

  3. Can we see instances/examples of when the redirect function is triggered?

    yes, we'll see some examples today.

  4. I think I'm still a little confused on the purpose of flash(). How is flash different from what we have already done in this class to render templates? I think seeing more examples/going over it in class would help.

    Flash is an easy way to have a general "messages" part of a response, for errors, updates, etc. It also has the cool ability of surviving a redirect.

  5. For flash messages, the reading says that there are 2 parameters, the message and the category, and that both parameters are optional. I understand what the message parameter does but what's the point of the category parameter if it's not imperative to have?

    You misread that. For flash() the second is optional, but the first is required. You have to say something.

    I think once you have categories, you'll probably always want to use them. Categories are a new feature; you don't have to use them, though you can distinguish, say, errors from updates.

  6. I'm confused by get_flashed_messages. The tutorial mentions something about category and removing a message, which I didn't quite understand. Could you give an example of when we would use this as opposed to flash?

    get_flashed_messages is not instead of flash. They work together.

    Imagine a jar of messages. flash() puts something in the jar. get_flashed_messages takes them out of the jar.

    We use flash() in our Python code to put things in the jar.

    We use get_flashed_messages() in our templates to display the message on the page (and remove them from the jar so that we don't display them more than once.