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


Talk Python's Mastodon Michael Kennedy's Mastodon