From the course: Full Stack Web Development with Flask

Unlock this course with a free trial

Join today to access over 24,400 courses taught by industry experts.

Passing data to the view

Passing data to the view

- [Instructor] Passing data to the view. In this video, we're going to look at how data can be passed from the source to the view, and we'll also highlight the active menu when a menu item is clicked. Also, we'll be using the For directive to loop through a dictionary of items, and using the For directive, we'll be building the courses table with some JSON data. So let's go see how this is done. Here in the sources files on the desktop, if you open this now, I added another folder called a models folder. Inside here is a courses.json file, just a text file, if you open this using Notepad or a text editor, we can go ahead and copy this first. And again, just a long string of data, as you can see. So I'm going to go ahead and copy, do a Control + A, copy all of it, you can close this now, and then go into the code. So inside Visual Studio Code here, I'm going to go open the templates folder, inside the routes.py and…

Contents