Quiz

  1. I am receiving a 404 error when I try to access the page "https://cs.wellesley.edu/~cs304node/apps/people/" - is there any particular reason why?

    You have a tilde in there that is not correct. You want https://cs.wellesley.edu/cs304node/people/

    The other folder exists, but it's not being served by Apache, since it's not in public_html.

  2. For the topic of redirects, from what I understand redirects don't really have any functional advantage, they are more of an aesthetic/preference kind of thing, is that correct?

    Hmm. I'm not sure I quite agree, but I can see your point. Redirecting when a page has moved isn't just aesthetic. Later, we'll learn how redirecting after a POST can avoid certain troubles with re-submission. But in terms of a preferred or authoritative link, you do have a reasonable point.

  3. When building a full-stack web database application using MongoDB, Express, and EJS, why is it important to use asynchronous handler functions, and how does this benefit the handling of database queries?

    Well, the API for MongoDB is asynchronous, so we have to use asynchronous handler functions when we access the database.

    Furthermore, having asynchronous handlers allows for greater concurrency: other requests can come in and be served (or, at least, initiated), while we are waiting for MongoDB to respond.

    That increase in concurrency is actually the reason industry is so excited by Node.js and MongoDB.

  4. I don't quite get how to use req.query.

    It's created by Express to hold the info from the query string: ?month=6

    It's a dictionary of key/value pairs corresponding to the key/value pairs from the the FORM that uses method=GET.

  5. I would love to go over the parameterized search in the People Born in a Month section

    For sure!

  6. Using the same EJS file with multiple pages

    If the EJS file is sufficiently generic, there's no reason not to reuse it. It's not common; in most cases, each kind of page will have its own template, but reuse is good when possible.

  7. Is the ejs strictly necessary for this or just more efficient?

    Coding should always be clear and easy to read. Using EJS means that HTML and other markup information is separate from the more functional code of handler functions, making our server.js file clearer and easier to read.

    You can imagine implementing without EJS or any other templating engine, but you'd probably end up re-inventing one anyhow.

  8. sync/async in EJS template files

    The res.render() method is synchronous, since EJS is rendering a template using data we already have. So we can't use asynchronous functions inside it.