Python for the .NET developer Transcripts
Chapter: Web frameworks
Lecture: Flask overview

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Let's talk Flask for a minute
0:01 before we start working with its API.
0:04 It's famous for having incredibly simple start-up story.
0:07 Create a single-file, put a couple lines in it
0:09 and, boom, you have a Hello World web app.
0:12 In fact, that's technically true
0:14 but it's not very realistic 'cause, in a real web app
0:16 you have a lot other stuff going on
0:18 and you shouldn't cram it all into one file.
0:20 You should actually have it structured well
0:22 so that your controllers are separate
0:23 from other parts of your app
0:26 like your data access layer and so on.
0:28 Nonetheless, Flask is really easy to get started with.
0:32 We're over here on the Flask documentation page.
0:34 It's part of this thing called the Pallets Project
0:37 which is Click, Flask, ItsDangerous
0:39 Jinja, MarkupSafe, and Werkzeug.
0:41 These projects basically make up Flask
0:44 plus Click is a little bit larger as well.
0:46 But it's all overseen by the same group
0:49 primarily by David Lord but also by other folks.
0:52 Now, the first sentence here is
0:53 Flask is a lightweight WSGI web application framework
0:58 or sometimes, that is pronounced wiz-gee.
1:00 I like to pronounce it as wiz-gee personally.
1:02 So what is WSGI?
1:03 WSGI is Web Service Gateway Interface.
1:06 Now, you saw there were that massive variety of web frameworks:
1:09 Flask, Django, Pyramid, and so on.
1:12 There's also a vast variety of servers
1:14 that run Python web apps. So we have Uvicorn.
1:18 We have Gunicorn. We have uWSGI.
1:21 We have a bunch of other things.
1:23 So, just like we have a simple choice with ASP.NET
1:26 in the C# world, you also have the simple choice of
1:28 Well, we're going to host this on IIS.
1:31 That's probably the most common way
1:32 to put ASP.NET web apps into production
1:35 and host them on IIS, Internet Information Server.
1:38 In the Python world, like I said
1:39 we have this wide variety of frameworks
1:41 and a wide variety of servers to run them in.
1:43 And this Web Service Gateway Interface is the common API
1:47 that allows an arbitrary framework
1:49 to plug into an arbitrary web server.
1:52 So you'll see this. You also may see ASGI.
1:55 This is the Asynchronous Server Gateway Interface
1:58 for the async enabled, more highly concurrent frameworks
2:01 but most Python web apps are these WSGI web apps.
2:05 Like a large portion of Python libraries and frameworks
2:08 Flask is, of course, open-sourced.
2:10 So here it is on GitHub,
2:14 And you can go get the code, check it out, even do PRs
2:17 and suggest changes to it, right?
2:20 Notice one thing over here.
2:21 It's pretty popular, 47,000 stars.
2:25 I just looked, right before I hit Record
2:27 over at the ASP.NET Core GitHub Repository has 14,000 stars.
2:34 It's a big difference. This is like four times more
2:36 and it's even more impressive
2:38 when you think of the fact, like
2:39 Well, yeah, there's Flask
2:40 but there's that huge variety of other options,
2:42 whereas ASP.NET, that's kind of the clear choice, right?
2:45 So this is a really popular web framework
2:48 and there's tons of tutorials, lots of documentation
2:51 lots of articles, and extensions
2:53 that you can plug in this framework.
2:55 It's a good choice to get started with.