#100DaysOfWeb in Python Transcripts
Chapter: Days 1-4: Flask Intro
Lecture: Setup your Flask app as a package

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Now that we have our virtual environment created
0:04 right there
0:05 we need to actually create our application
0:08 directory hierarchy setup, okay?
0:11 What we're going to do, which is the more Pythonic way
0:15 of doing this, I suppose, is actually package
0:18 our Flask application.
0:20 This package is going to host our application.
0:23 The reason we're doing this is just to allow
0:26 the app to be imported at a later date.
0:29 It's more about scalability and growth
0:31 and everything like that.
0:33 You can actually just create a Flask app
0:36 as we did in one our previous courses
0:37 just with a single file
0:39 but this is the better way of doing it
0:42 and, as I said, it's more scalable.
0:44 So, with that said take a look at this.
0:49 This is what our hierarchy, or what our folder directory
0:54 structure is going to look like.
0:56 We have here our parent directory.
0:57 That's the Flask folder.
0:59 And we have our virtual environment here.
1:02 What we are going to create is our Python file
1:06 that defines our Flask application.
1:09 It's nothing crazy. It's just one line of code, so we'll see that going forward.
1:13 I just wanted to point that out.
1:15 The meat of our application is going to live
1:17 within our folder here, which we're creating our program in
1:21 so, I've decided to name it "program".
1:24 We have our parent directory.
1:27 We have the program directory
1:29 which is going to house the meat of our application.
1:32 This is the package.
1:35 Inside that, we have the dunder named file
1:39 so it's a __init__.py file.
1:42 That is what denotes that this is a package
1:45 that this is a Python package, that can be imported.
1:48 It has the rules in there, in that __init__.py file.
1:51 And the bulk of our application is then run
1:55 out of the routes.py file, as you can see down there.
1:59 The routes file is going to create all the routes
2:03 all the webpages, all the links for our application.
2:07 It's going to have all the Python code in it.
2:09 There will be other folders going forward
2:11 but this is what we're creating now.
2:14 So, go ahead, create a folder called "program".
2:17 That is going to be your application directory.
2:21 Create a demo.py file. It's just going to be blank.
2:25 Create, within your program directory, an init file
2:29 __init__.py, spelled exactly like that
2:32 and a routes.py file.
2:35 So, give that a go, and when you're done
2:36 it will look something like this.
2:46 Okay, so we have our demo.py.
2:48 We have the program directory.
2:50 We have have __init__.py and we have routes.py.
2:53 Leave it there. Let's move on to the next video.