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


Talk Python's Mastodon Michael Kennedy's Mastodon