• is there a particular reason why not all quizzes are posted so that we can do them more than one day in advance at our own pace? Just wondering.

    Remember: the idea is that you can do the reading whenever you have time. The quizzes are meant to be done separately. In fact, it's better, pedagogically, to quiz yourself a bit later than when you did the reading.

    I'm not sure what you mean by "at your own pace". The quizzes are intended to be short. Over half the class did this one in less than 5 minutes, which is what I intend. Several did it in less than a minute. I allow 30 because I don't want you to feel time pressure, and I know that some folks get 1.5x time on quizzes, so 30 minutes seemed more than sufficient.

    But I don't want people to open the exam, read over the questions, and Control-F for the answers. I know people do that anyhow, but still.

    Let me return to the other half of your question: why not release them all at the beginning of the semester? I have several reasons:

    But let's take a poll: how many would like me to release all the quizzes for the rest of the semester now?

  • Can we review question 1 in class?

    Sure. Here's the question:

    If we POST a form with the empty string for the ACTION, the data goes
        A. to the same handler as sent the form
        B. to the home page
        C. to the index page
        D. to the url specified by the processor variable
    
  • I'm still a little confused about using ""ACTION"".

    A few years ago, I thought it was useful/interesting to have an empty string for the ACTION, which allows for forms that could be used in different contexts.

    But later, I learned that such an action can create a web vulnerability.

    So, rather than completely eliminate such examples, I decided to keep that in the reading and explicitly warn against using ACTION=""

    Apparently, I've confused some of you, and I apologize for that. I'll revised the reading for next year.

  • under what circumstances will we be using <form method=POST action="{{url_for('form1')}}">? why would we want to go to the current URL?

    Always. You should always specify the url for the ACTION in template.

    We don't want to go to the current URL.

  • Can we talk more about the nav bar?

    Sure. Here's a link to the flask-starter code

  • What is the difference between a flask starter directory and just using HTML/CSS/JS?

    Well, the flask-starter directory has an app.py file in it that has all the necessary import statements and such to get us started. That's actually the most useful thing, in my opinion.

    You can use your own HTML/CSS/JS, maybe from Bootstrap or something.

  • Can you change the css formatting of one part of a template that inherits another one? How much of a child template can be changed before it cannot inhert a parent template?

    You can have a replaceable block that adds another CSS file or style tag. You could even put CSS directly into the HTML, but that's considered poor style.

    The parent determines what can/can't be changed. So the child can always inherit, though if the child doesn't replace anything, it's not really useful.

  • 1. How does template inheritance work when more than one child template exists for the same base or parent template? What blocks are replaced?

    The render_template command chooses the template to render. If there are 17 child templates that inherit from a single base template, there are 18 choices.

    The child determines which blocks are replaced.

  • I don't think I completely understand how post/redirect/get handles when we don't want to resubmit data and when we do want to resubmit data.

    We would almost never want to re-submit data if POST is being used properly, because POST should be updating/modifying the state of the application or the database, and we rarely want to do that in the same way with the same data.

    However, sometimes, people mis-use POST. The example in the reading is LTS's classlist application.

    In that case, people might want to re-submit.

    In any event, the Post-Redirect-Get pattern puts the browser at a page where reload will be a GET request, which is harmless to reload.

  • Is the a maximum number of routes an app should have? Is it better to typically have more/less routes?

    Doesn't matter. Create the routes you need and want, and don't worry about the number.

  • I am not really sure about Post-Redirect-Get.
    @app.route('/ask_city/', methods=['GET','POST'])
    def ask_city():
        if request.method == 'GET':
            return render_template(
                'city_form.html',
                cities=countries.known.keys())
        else:
            city = request.form.get('city')
            # redirect is a new import from flask
            return redirect(url_for('country',city=city))
    
    Can you go over how the POST-redirect-GET is used in the Flask route above? "

    Sure. The first branch sends a page with a blank form. The second branch processes a filled out form and redirects to the country page.

  • I do not have a specific question for now but I'm sure I will have more in the future when implementing my project.

    I'm glad to answer questions then.

  • Indeed, one reason I was initially reluctant to commit to Flask in CS 304 is that I worried that it would be hard to remember all these pieces, and I haven't been entirely wrong."" What other alternatives were considered (out of curiosity)?"

    I briefly considered Django, but it seemed more complicated than Flask.

  • I'd like to see a demo of the flask-starter! / Could we get a demo of the starter directory working? / I think a demo of the starter app would be helpful!

    Let's do it!