Quiz

  1. How do we organize our python corresponding to our database vs to our HTML?

    Great question!

    First, the database is separate; it's maintained by the DMBS server and we manage it by connecting via the mysql client or our python scripts/programs. So there's nothing to "organize" there.

    Of course, you might have .sql batch files that you use to set up your project tables, and create the initial data. Lots of project teams have batch files that clear out test data and reset the project tables to some clean initial set. I suggest you put all these in a "build" subfolder of your project folder. I just made up that name; you could also call it "setup" or "db-init" or any of lots of names.

    Your python files you will put in your main app folder, next to your app.py. You can also put them in subfolders if you like, but there typically aren't many of them, and putting them in the main folder makes import easy.

    Your HTML template files will be put in the templates subfolder of your main folder.

    We'll see a fully fleshed-out example next time.

        my_app/
            app.py
            other.py
            helper.py
            build/
                setup.sql
                init.sql
            static/
                style.css
                logo.png
            templates/
                base.html
                index.html
    
  2. How does Jinja2 prevent cyberattacks or, what are coding practices we can follow in Jinja2 to prevent them ourselves?

    Another good question. We have a reading/lecture devoted to security later on, where we will talk about XSS attacks and how Jinja2 helps thwart those. For now, there's no need to worry.

  3. I'm confused (like how/when do we choose between dictionaries, loops, and conditions), but I think I just need practice!

    Understandable. This is new for all of us. You'll get it soon enough.

  4. Not super related but why do web domains need buying, why is that something that is treated as a service

    Interesting question. There has to be some entity that decides who controls a given domain, and the mapping between a domainname and an IP address. IP addresses are limited, and any limited resource needs to be managed. That's done by the Internet Assigned Numbers Authority (IANA) and by Internet Corporation for Assigned Names and Numbers (ICANN)

    They delegate part of the job to various Domain Name Registrars.

    Although ICANN is a 501(c) non-profit, both it and the various registrars deserve some funding for their work. It's usually not an onerous charge. It costs me $22/year for various domains that I own.

  5. No questions, thank you!

    You're welcome!