#100DaysOfWeb in Python Transcripts
Chapter: Days 1-4: Flask Intro
Lecture: Setup your Flask app as a package
0:00 Now that we have our virtual environment created right there we need to actually create our application directory hierarchy setup, okay?
0:12 What we're going to do, which is the more Pythonic way of doing this, I suppose, is actually package our Flask application.
0:21 This package is going to host our application. The reason we're doing this is just to allow the app to be imported at a later date.
0:30 It's more about scalability and growth and everything like that. You can actually just create a Flask app as we did in one our previous courses
0:38 just with a single file but this is the better way of doing it and, as I said, it's more scalable. So, with that said take a look at this.
0:50 This is what our hierarchy, or what our folder directory structure is going to look like. We have here our parent directory. That's the Flask folder.
1:00 And we have our virtual environment here. What we are going to create is our Python file that defines our Flask application.
1:10 It's nothing crazy. It's just one line of code, so we'll see that going forward. I just wanted to point that out.
1:16 The meat of our application is going to live within our folder here, which we're creating our program in so, I've decided to name it "program".
1:25 We have our parent directory. We have the program directory which is going to house the meat of our application. This is the package.
1:36 Inside that, we have the dunder named file so it's a __init__.py file. That is what denotes that this is a package
1:46 that this is a Python package, that can be imported. It has the rules in there, in that __init__.py file. And the bulk of our application is then run
1:56 out of the routes.py file, as you can see down there. The routes file is going to create all the routes
2:04 all the webpages, all the links for our application. It's going to have all the Python code in it. There will be other folders going forward
2:12 but this is what we're creating now. So, go ahead, create a folder called "program". That is going to be your application directory.
2:22 Create a demo.py file. It's just going to be blank. Create, within your program directory, an init file __init__.py, spelled exactly like that
2:33 and a routes.py file. So, give that a go, and when you're done it will look something like this. Okay, so we have our demo.py.
2:49 We have the program directory. We have have __init__.py and we have routes.py. Leave it there. Let's move on to the next video.