#100DaysOfWeb in Python Transcripts
Chapter: Days 1-4: Flask Intro
Lecture: Day 4: Your Turn - What did we learn?

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Congratulations you made it to the end of your first
0:03 two days of the course.
0:06 This was the introduction to the Flask Web Framework.
0:09 I hope you enjoyed it, I hope you got a lot out of it.
0:12 Let's do a quick recap of everything that we learned.
0:15 What we're looking at here is the Flask package hierarchy
0:18 this is pretty much how our entire application was laid out.
0:22 If you remember we started out with our project folder
0:25 we created the virtual environment, we have our demo.py
0:29 file which tells the flask app what to run
0:33 and we also have the flask n file there
0:36 which was the actual environment variable for the flask app.
0:40 We then had the program folder, that's where our actual
0:43 application lived, it was packaged within that
0:47 and that's denoted by the __init__.py file that tells
0:50 the package what to run, what to import and so on
0:54 and it imports the routes.py file which contains
0:58 all of the information for routing out applications
1:02 so all of your routes, the app.route decorator
1:05 and what each one of those web pages actually does.
1:10 We then have the templates folder which contains all
1:13 of those html templates including the base template which
1:17 was the one that carried across all of our pages
1:20 and then we have our two unique pages, index.html
1:24 and 100Days.html.
1:28 Just looking at our __init__.py file quickly, we begin
1:32 by importing flask, that's the very first thing you have
1:35 to do for this file, you have to tell it to import
1:38 the flask module from the flask package, and then
1:42 we create our very own flask app object.
1:45 So we get this app object and that's what's used throughout
1:49 all of our application.
1:52 We then from our program folder
1:54 we import the routes.py file, so thinking back
1:58 to that hierarchy, from the program folder
2:00 we're importing routes.py.
2:05 Looking into the routes.py file, we import app
2:10 so again from that program folder we know because of the
2:14 __init__.py file that we can import our flask object
2:18 called app, from flask itself we then import render_template
2:23 and looking down a little bit further, we then have our
2:27 decorators, these are the decorators that sit on top
2:30 of our function, and these tell our function what path
2:35 is going to work with that function
2:39 and at the end of the function we then return the actual
2:42 html file or the template that is going to be used
2:46 when that page is called.
2:49 Looking to the base.html file now, this one's quite simple
2:53 nothing much to it, it was just some base html code
2:57 with some Jinja code injected right into the middle
3:00 of the body tag, this again was the place holder of all
3:03 of the content that we're going to be injecting into
3:07 this base html file, and that code that we're injecting
3:11 in is our unique html files
3:14 and looking at those unique html files, those other pages
3:19 we then have the extends Jinja code and that tells us
3:23 what file we're extending from, in our instance
3:27 we're extending from base.html, taking that base html code
3:33 that template, and using it for this other page.
3:39 The block content as we saw in the base.html file
3:42 this is the code that's going to be injected, this is
3:44 the code that fits within that block
3:46 content on the template
3:51 and last but not least we then played with a little bit
3:54 of MUI CSS, this is just a screenshot of the website
3:57 there's the URL down on the bottom, if you want to have
3:59 a closer look, have a bit of a play.
4:01 So now it is your turn, have a quick look at the video
4:05 again on the read me, or go and read the read me yourself
4:09 on the actual GitHub repo but now it's up to you.
4:12 In your last two days you are going to make your own
4:16 web application, the idea is to be completely free form
4:19 there is no rule around this, all I'd like you to do
4:22 is take everything you've learned and make your own
4:25 website, make your own page, it doesn't have to
4:27 be functional just as long as you are using a base
4:30 html type file to have a template that flows
4:34 across all of your pages, do whatever you want
4:38 come up with anything, make it as simple as possible
4:41 it doesn't matter, just remember it's all about
4:44 the consistent learning, so day three and day four
4:48 dedicate at least 30 to 60 minutes to just playing
4:51 around with your own website and remember
4:54 keep calm and code in Python.