Chrysolites Tech Academy

Video by freeCodeCamp.org · taught by David J. Malan · streamed from YouTube. All rights remain with the creator.

Lesson 8: Web Programming with Flask

About this lesson

This lecture combines the web languages of earlier weeks with Python to build dynamic web applications, pages that are generated by a program each time they are requested. It introduces Flask, a lightweight web framework for Python, starting with the smallest possible application and explaining how a route connects a web address to a Python function. You see how an application reads parameters from the address, and how templates written in a language called Jinja let HTML pages contain placeholders and simple loops and conditions, so that the same page can show different content. The lecture shows how a shared layout template avoids repeating the same HTML on every page. It then builds a registration application step by step, using forms that send data to the server by GET or POST, and stresses the importance of validating input on the server as well as in the browser. Along the way it considers where submitted data should be kept, from a simple variable in memory, which is lost when the server restarts, to a file such as a CSV spreadsheet that persists. The lecture explains how websites remember visitors from one request to the next using cookies and sessions, with an example in which a user logs in. It introduces the model, view and controller pattern as a way of organising the parts of an application, and shows how the server can also return data for JavaScript in the browser to use, so that pages update without reloading. Afterwards, read Chapter 8 of the course book, which traces a form submission from start to finish.

Install Chrysolites Tech Academy

Android / Chrome / Edge: open the browser menu and choose Install app or Add to Home screen.

iPhone / iPad (Safari): tap the Share button, then Add to Home Screen.