My CS50 summary: Flask

Happyday
2 min readJun 21, 2021

A web server is just a piece of software that’s constantly listening on port80 or port443 in terms of TCP recall, and it’s just listening for connections. And any time your browser connects it looks at the UTL that you visited and maybe some parameters that you may have provided via that URL, or more generally via a form, and it serves up a web page, optionally with some kind of output.

And we’re going to introduce you to a library called Flask. And technically specking, Flask is also called a framework. A framework is a way of doing things. It’s a way of organizing and writing your code that more specifically is just how you should use this library.

Frameworks are not just libraries where they have functions that you can call. They typically have documentation that says, to use these functions, you should additionally organize your files and folders in this way.

  1. application.py 2. requirements.txt 3. static/ 4. templates/

A design pattern is just a fancy ways of describing ways that humans write code. Suffice it to say over the past many decades, a lot of humans again and again, and they realized, wow. I’m noticing patterns in how I’m solving a problem for this project and for this project and for this project and another. And once human programmers noticed these patterns, they might formalize them by writing a book, by writing a blog post or the like, and then give them a name, a design pattern that they recommend that other people adopt. Why? Just because it helps you organize your code instead of putting all your code in one massive file, well maybe if we put some code here, some code here, we can collaborate more effectively with others and just keep ourselves sane when maintaining bigger and bigger projects.

MVC(MODEL, VIEW, CONTROLLER)

A template is kind of a framework into which you can plug other values.

Google is running some program, maybe it’s Python with Flask, maybe it’s some other language that’s analyzing the URL, grabbing q equals cats, and then they’re searching their database essentially for a keyword of cats, and then they’re dynamically generating the HTML that shows you all of those pictures and search results of cats. … Suffice it to say that’s all dynamically generated.

--

--