#100DaysOfCode in Python Transcripts
Chapter: Days 76-78: Getting Started with Python Flask
Lecture: Concepts: what did we learn
Login or
purchase this course
to watch this video and the rest of the course contents.
0:00
Alright. Let's quickly cover off everything we've learned and leave it to you, So, a basic Flask app, that's pretty much what we did. Okay?
0:11
We did add some data in there, which is what made it a little more fun and approachable and usable. So the first thing we had to do is import Flask
0:19
and render_template, as well as the dictionary information. The render_template we will get to. We then declared the Flask app object and importantly,
0:33
we added that app.route decorator to the index function and that allowed us to get to the URL of route and execute this code,
0:46
and then we returned the dictionary to this index HTML, using render_template. That was very important for us to talk to the Jinja template
0:58
and finally we ran the app with app.run(). Remember, you need that line. Don't forget it or your app is not going to run.
1:06
As for the Jinja template, the HTML, I've narrowed in on just the important parts here. Alright, we create the table using our normal HTML and css,
1:15
whatever it is you might use, and then we execute the Python code. Alright, so we've got our for loop there,
1:24
to pass through, to iterate through the dictionary and the items so keys and values, and remember, super important,
1:35
your curly brace with the percentage sign that denotes the code that will be executed. We then use these substitution brackets,
1:46
these double curly brackets on either side and that's how we print or display the data in this key and this value within this for loop,
1:57
remembering that every pass of this for loop is going to create this table row with the data. Alright, and finally, just as important,
2:08
you have to close the for loop. You have to end it using this syntax, endfor. And when we run it on 127.0.0.1 local host, port 5000,
2:21
this is what we got, really, really awesome stuff. Okay? And now it is your turn. Take everything you've learned and try to make your own app.
2:34
Try and make your own custom app based on some sort of a dictionary or list or whatever you can think of
2:40
and enjoy that for day three and move on to the next video.