On my quest for a good Flask book, I saw this book from Tarek Ziade. We are more or less of the same generation, both from France and he wrote a far better introductory book to Python in French than mine. He also founded the French Python community (AFPY), so I always had a huge respect for the guy. And the book was appetizing.
Discussion
The first chapter tackles the design decision of going to microservices. Even if Tarek is clearly biased towards microservices, he does make valid points of the evolution of the infrastructure when you have clean separation of purposes. After all, in your classic LAMP setup, you do separate the code from the data, this is just separating the code and the data in more elemental aspects. The second chapter tackles Flask basic design decisions. Compared to my previous review, this book wants the user to understand how Flask works and how to setup the equivalent of a hello world.
The next chapter is the one missing in lots of coding books: testing. This is probably the best chapter in the book because it’s there and I was looking recently online for hints on how people did testing on the webservices (unit, functional, integration and regression). It is well explained with different tools to use, and I’m now using them almost as is.
The fourth chapter tackles the creation of the example application that the book turns into a set of microservices. From a simple prototype design where everything is in the same application, we start splitting it up in parts. We also have the introduction of Swagger/OpenAPI which is a good way to document your application. We see here how a swagger description feeds to an implementation, I’m more of the other camp, having an implementation generate a swagger description, but I understand this point of view as well. We are at OpenAPI 3.0, and there is no community-supported implementation of flask-swagger for it (at least not for the flask-restful package).
We then tackle the types of calls that we can do, synchronous or asynchronous, between webservices. As lots of services can be asynchronous (like email send), this is a great presentation of how to implement both and on what to use to implement the message queue for asynchronous calls. Of course, there is also a section on how to test and mock the backends for these. So here as well, we have good practices at work.
Maybe the most forgettable chapter, the sixth chapter is about logging and metrics. The tool that is mainly presented, graylog, got a major version since the book was written, and there is a crucial lack of documentation to make it work in a docker environment (which is where all the microservices would run at the beginning, that’s actually also something that is awkward here, as we don’t see how to run all the services together at this stage).
I waiting on the authentication chapter for quite a long time. I was reading the book, and I was thinking “OK, but how to you tackle multi-user and data privacy?” for quite some time. I think this chapter should have been the fifth one, just after the first prototype of the application, to have security as a central aspect of the application. The concept of authentication via tokens and flask-login is properly introduced, as well as the current OAuth standard.
The eighth chapter binds the UI to the other services, we see a first quick introduction to React (I think at this stage, due to the even faster evolution of the JS landscape, plain HTML should have been enough, or some basic AJAX, but not bower, which was deprecated almost at the same time than the book was released…) and how to tie it to the token service.
I have read the last three chapters really quickly, as I wouldn’t use Python packaging tools for web deployment, that’s what Docker and Docker compose are for. They are tackled in the tenth chapter, and even if I decided to go for another server stack, the ones presented in the chapter are very good alternatives, and I may use them in the future instead of nginx (as I have another reverse proxy in front of my test projects, the fact that nginx also is a reverse proxy doesn’t matter, I just want a very good server). At the end, we have the traditional how to deploy on the cloud chapter, and here we have AWS. We have all the steps required to deploy our docker images to Amazon cloud, which is what we want to have.
Conclusion
What could be lacking in the book is a presentation of Babel (for multi-language support) as well as a small build farm (AWS?) for test automation. But the book is not about creating and testing the example app, it’s more about the concept, and one should use their own pet project while reading each chapter and applying this new knowledge on it.
Even if Flask ecosystem evolves really quickly, the worst flaw of the book is still the fact that once the microservices are introduced, it is difficult to follow how the project evolves, what we did and what needs to be done. Perhaps a few intermediate releases on a unique repository would have made more sense to show the state of the implementations.
Still all the good ideas are in the book, so definitely a book you need to read.
[amazon template=iframe image&asin= B01N7N7BU9]
[amazon template=iframe image&asin= 9781785881114]