Building Data-Driven Web Apps with Flask and SQLAlchemy Transcripts
Chapter: Introducing the Flask framework
Lecture: What are microframeworks?
0:00 Now it's time to dig into Flask.
0:02 And let's just think a little bit about
0:04 choosing a web framework and where Flask might live
0:07 on this spectrum of frameworks.
0:10 In my mind, there's two ends going on here.
0:13 On one end, we have what are called microframeworks.
0:15 Microframeworks let you choose exactly the set of libraries
0:20 and packages you want to use and put them together
0:22 as you like, without the framework imposing how that works.
0:26 So over here, I would put Flask here
0:29 what kind of data access layer do you want?
0:31 Well, Flask doesn't care doesn't come with one
0:33 and it doesn't impose any structure there.
0:35 Maybe you want to go get SQLAlchemy
0:37 maybe you want to get MongoDBs through MongoEngine
0:40 or maybe you want to do something entirely different, right?
0:42 Flask doesn't have an opinion
0:44 or any implementation along those lines.
0:48 The other end of the spectrum doesn't have a great term
0:50 like microframeworks.
0:52 But what I'm calling these are building-block frameworks.
0:55 And these are things like Django.
0:57 With Django, you can create a website
1:00 create a project and you say
1:01 Oh, I would like a whole back end
1:03 where I can just edit the database fields
1:05 kind of like Excel type of thing.
1:08 That's like a line in the configuration file
1:10 boom, that's turned on.
1:11 I want forums or something like this
1:13 I want to plug these big building block pieces together.
1:17 That's really productive and great if that's what you want.
1:19 But if you don't like the way Django does database access
1:22 well, sorry, Django does it that way, it's very opinionated.
1:27 Not to say you can't work your way around it
1:29 or do something different
1:30 but you're always going against the grain, right?
1:32 So Django helps you by giving you a bunch of steps
1:35 and opinions, here's how you do it, here's the libraries, go
1:39 which is sometimes okay and great.
1:41 But if you are the type of person
1:43 that likes to pick just this library, and just that library
1:46 and put things together the way you like
1:48 well, microframeworks are probably better for you.
1:51 Now Flask is not the most micro of the microframeworks.
1:54 We have things like Bottle that live way out there
1:56 that do very, very little at all.
1:59 And then we have Pyramid
2:00 which is maybe a little bit towards Django
2:03 a little bit less microframework
2:05 but still well in this microframework side of the world.
2:08 So here's how Flask fits together with all of the others.
2:12 And I think Flask is a great choice.
2:13 I'm personally a big fan of the microframework style.
2:18 Makes me happy to be over on the left side of this graph
2:21 generally speaking, but I know Django is also very popular.
2:24 And speaking of popularity
2:26 Flask and Django are almost identical
2:29 at the time of this recording
2:30 with Flask actually growing in popularity
2:32 relative to Django.
2:33 So I guess the world is about split 50/50
2:36 on which side of this graph they want to live on.