Eve: Building RESTful APIs with MongoDB and Flask Transcripts
Chapter: Introducing Flask
Lecture: Why a micro web framework

Login or purchase this course to watch this video and the rest of the course contents.
0:01 Before we dwell on Eve itself, we really need to talk about Flask.
0:05 Why, you ask?
0:07 Firstly, because Eve is built on top of Flask, keep that in mind
0:11 because it is very important and powerful.
0:13 Anything you can do with Flask, you can also do with Eve,
0:17 that is remarkable, because by leveraging Flask and Eve,
0:21 you end up being able to fine tune, extend and customize
0:24 basically every single feature that comes with the framework itself.
0:28 So in this section, we will make ourselves comfortable with Flask
0:32 and trust me, it will be worth it.
0:35 Once we move on to Eve in the next sections
0:38 you will be amazed at how comfortable you feel sitting at the Eve wheel.
0:42 Now if you look at the Flask about page
0:45 you see that Flask tags itself as a micro web development framework,
0:49 what does it really mean?
0:51 Micro doesn't mean that the web app
0:53 has to fit into a single Python file of course,
0:55 nor does it mean that Flask is lacking in functionality.
0:59 The micro in micro framework actually means
1:02 that Flask aims to keep the course simple, but extensible.
1:05 Flask want to make many decisions for you
1:09 such as what database to use,
1:11 those decisions that it does make however, are easy to change.
1:14 Everything else is up to you
1:16 so that Flask can be everything you need and nothing you don't.
1:19 Again, being micro doesn't mean lack of functionality,
1:23 let's look at its acclaimed Restful request dispatching for example;
1:28 here we are looking at two possible roads for our apo,
1:31 one, obviously being the home page
1:33 and the other one being a Hello URL.
1:36 As you can see, we are using a decorator to instruct Flask
1:39 on which functions should be run when a user hits a certain URL or endpoint.
1:44 How nice is that?
1:46 There is more to it, of course,
1:48 like the option to add variable parts to you URL to use.
1:51 But you can already see how Eve could easily
1:55 leverage and build on top of this feature
1:58 to provide an out of the box, yet powerful and easy to use routing mechanism.
2:03 Flask also comes with a built in development server and debug support.
2:09 This is super important when you are prototyping
2:12 and then writing web apps.
2:14 You get all sorts of debugging formations,
2:17 like stack traces and variable inspection
2:20 just by setting an environment variable as we see here.
2:23 In the following line, we see how easy it is to launch the application itself.
2:28 This is possible, because Flask comes with its own development server
2:32 which is more than good enough to play and test the app
2:36 before going into production.
2:39 There are many other nice things that are coming with Flask
2:41 and one of my favorites has got to be the integrated support for unit testing.
2:46 When you're building a framework
2:48 you want to make sure that it is well tested.
2:50 That is true for any kind of web app really,
2:52 but if your end users are going to be developers,
2:55 well, you want to make your test as complete and effective as possible.
3:00 Flask native support for unit testing
3:02 which we can see at work in this course snippet, is a key feature,
3:06 and we have of course been abusing it while developing the Eve framework.
3:10 If you're going to write your own web apps or frameworks with Flask,
3:13 you really want to get to know everything about testing Flask
3:16 and of course, its debug mode and development server.
3:20 So Flask is cool and it is fun.
3:22 It is easy to set up and use, but being micro by desine
3:27 doesn't come with the tons of a high level features
3:30 such as database access or an admin backend.
3:34 Luckily and precisely because it is micro, powerful and easy to extend
3:39 over time a huge number of Flask extensions have surfaced
3:43 and are now available for you to use.
3:45 The extensions' registry is loaded with all kind of useful tools
3:49 which you can plug into your app and most of the times Eve too,
3:53 and then be on your way,
3:55 or you can build your own extension
3:57 and then contribute it to the community.
4:00 In fact, one of the reasons why Flask is so popular
4:02 is because it is very easy to build on top of it,
4:05 and in any case, the extension registry is at your fingertips
4:10 where you don't feel like reinventing the wheel.