#100DaysOfWeb in Python Transcripts
Chapter: Days 1-4: Flask Intro
Lecture: Create __init.py__

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Okay, we're going to set up
0:02 each of these files, one at a time.
0:04 Let's start with the __init__.py file
0:06 cause that's arguably the most important file here.
0:10 To begin, let's start our virtual environment.
0:13 If you don't already have it, activate it.
0:17 Okay, in the folder we have demo.py program
0:22 and virtual environment.
0:23 Let's head into our program directory
0:25 and there is the __init__.py file we created.
0:29 So use whatever editor you want to just pop into that
0:32 and what we need to do is we need to first import flask.
0:37 So if you've ever done a single file flask app before
0:42 you keep the actual importing of flask
0:45 and the configuration of your app object, your Flask object.
0:49 That all happens in the one file
0:51 where your routes is stored and everything. Not so here.
0:55 Your __init__.py file is going to actually
0:57 configure flask for you and tell the package what's what.
1:03 Alright. What we want to do is insert.
1:08 So, I forgot for second there I was using Vim.
1:11 So we're going to do from flask.
1:13 So from flask import Flask.
1:18 And then we're going to create.
1:21 This is where we create our application
1:24 our flask application instance.
1:28 Now this is going to create the flask instance
1:31 using the name of __name__.
1:38 Now, here's where the magic is.
1:41 We're going to do another import here
1:43 from our program directory that we're already in.
1:48 Alright, we're already in it.
1:50 We're going to import the routes file.
1:53 Now this has to happen below
1:56 where we create the app instance
1:59 because we need that app instance
2:00 to be created first before we can import any of this.
2:05 So, the order of our file is to import flask
2:08 it's to create our Flask app instance
2:11 then once it's created, import the routes file
2:17 from the program directory that we're in.
2:20 Alright, that's it. Lets write that.
2:26 Lets cut it. And there it is.
2:31 All right, next video, next file.