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