Quiz

  1. I am still somewhat confused about the function loading/ routing.

    For sure. When a Python program starts, it loads any .py files, which define functions, and runs that code. Later it exits.

    In CS 111, it exits in milliseconds. In CS 304, Flask starts an infinite loop and the program exits when we type ^C (control-c).

    In Flask, the goal is to take an incoming HTTP request and route it to a function that will handle the request.

    We write the handler functions.

  2. If you aren't using a template, where do you write the html and css for a page that uses flask? And can you update specific lines of HTML using route functions?

    Your handler function has to reply/respond to the request with a web page: HTML and CSS. It can do that however it wants to.

    Next week, we'll learn about templating, which will make life much easier. For now, keep it simple.

  3. Whenever we work on flask applications going forward, will we only be using the terminal on our personal computer? Or is this still on VSCode (maybe I missed this in the readings. I know there's also a way to choose venv in VSCode...)?

    This is a great question. We have several pieces of the puzzle:

    • The web browser (the front end)
    • The Flask/Python software (our middleware)
    • The MySQL DBMS (the back end)

    In principle, all three could be running on your laptop, all three on the CS server or pretty much any arrangement.

    What we will do is the following:

    partwhere
    browserlaptop
    FlaskTempest
    MySQLdTempest

    That means you'll use VSCode remote development so that you are logged into Tempest to run Flask.

  4. I'm also confused about the whole id and port thing for URLs.

    Because we are all logged into Tempest, concurrently, we can't all use the same port. (Usually port 5000 or 3000.)

    So, we all need our own port number.

    Since we all already have our own UID number, I decided to use that as the port number.

  5. Are there any other equivalent or similar frameworks like Flask that are used across the industry? Or is Flask the most popular tool used in industries currently?

    Yes! The two major players in the Python world are Django and Flask. Flask is "lightweight" and doesn't do as much for you. Django is a bit more "heavyweight" making it harder to learn.

    There are web frameworks for other languages, such as Javascript (Node.js) and Express.

  6. How is flask different from other python web frameworks?

    Django does more stuff. It also uses an ORM (Object-Relation Model), where tables (relations) are mapped onto Python objects.

    I've chosen Flask, and I've been pretty happy with it.

  7. If Flask is already a web server in development mode, why do we still need Apache or another server in production mode?

    Because development mode isn't quite industrial strength. For example, there's no concurrency. Real web servers in production mode have to handle concurrent requests. We'll talk about that later in the course.

  8. I generally understand the concepts of Flask, but I would just like practice with it before our homework assignment on it (as this is all new to me).

    Of course!

  9. This chapter was pretty clear! / None for now!

    Great!