#100DaysOfWeb in Python Transcripts
Chapter: Days 1-4: Flask Intro
Lecture: Run your Flask app!

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Okay, time to work on that demo.py file so just head up one directory back to our one Python Flask directory
0:10 and there's your demo.py file that you created. Let's just Vim into that and all we really have to do in this file, is we're telling Flask what to do
0:20 so when you run the Flask command to launch your app which I'll show you straight after editing this this is the file you point at
0:28 because this is what kicks it all off. This is what tells it what package to use and so on. So, all we have to do is go, whoops
0:37 from program, import app. Now the reason this sounds confusing is because we're importing app and we've referenced that before in other places
0:48 so let me just walk you through it really quickly. Save that. Let's just verify it. Okay, so from program import app.
0:59 Now, this is talking to the __init__.py file. So we have app in here. What we're saying is, from our program package
1:12 import the app instance, or the app object of Flask and then, from there, it's going to do this one
1:21 from program import routes and reference the routes.py file. Alright? It just sort of goes through that tiered approach.
1:29 Now, we head back up. One last thing we need to do before we actually run this program is tell Flask, the Flask command, to use demo.py
1:40 and we do that through an environment variable. Now, this environment variable is set differently in Windows from macOS or Linux.
1:50 If you're using any sort of Unix environment you'd be used to using this method. So, export Flask underscore app
1:59 and then we want to talk to the demo.py file and that works. Now, in Windows, we can't do that
2:06 because you can't set environment variables using export. We have you use the actual set command. So, set FLASK_APP=demo.py
2:17 and then we go. So, if you're using Mac, use export or if you're using macOS or Unix, whatever and if you're using Windows, use the set command.
2:26 Now, all we have to do, is flask run. Okay, and you can see we are running our website on That's localhost, port 5000.
2:42 So, let's bring up a web browser and check that out. So, I've just opened up a web browser here. This is Google Chrome in incognito mode
2:50 and I've just punched in the URL or the IP address, and that's it. We see the returned string that we had in our routes.py file, okay?
3:05 In the background, we see the actual timestamp. We see the address that we're talking to. We see the URLs that were requested.
3:15 Just ignore this one. This is a remnant from a bookmark I had in there and that's it. There's our very first Flask app.
3:23 What I'd like you to do now is just have a play around with the routes.py file. Add in some other return values. Do whatever you want to play with
3:31 but this should be long enough to get you through today and possibly a second day depending on how much time this took you.
3:37 Just have a play, have some fun and let's move on to the next video.

Talk Python's Mastodon Michael Kennedy's Mastodon