Preface
Flask is a web framework for Python that is specifically designed to provide the minimum amount of functionality that is needed to create web apps. Unlike other web frameworks, especially those in other languages, Flask does not have an entire ecosystem of libraries bundled with it for things such as database querying or form handling. Flask instead prefers to be an implementation agnostic.
The main feature of this setup is that it allows the programmer to design their app and their tools in any way they want. Not providing their own version of common abstractions also means that the standard library can be used much more often than other frameworks, which guarantees their stability and readability by other Python programmers. Because the Flask community is rather large, there are also many different community-provided ways of adding common functionality. One of the main focuses of this book is to introduce these extensions and find out how they can help avoid reinventing the wheel. The best part about these extensions is that if you don't need their extra functionality, you don't need to include them and your app will stay small.
The main downside of this setup is that the vast majority of new Flask users do not know how to properly structure large applications and end up creating an unintelligible and unmaintainable mess of code. This is why the other main focus of this book is how to create a Model View Controller (MVC) architecture with Flask apps.
Originally invented to design desktop user interfaces, the MVC setup allows the data handling (models), user interaction (controllers), and user interface (views) to be separated into three different components.
Separating these three different components allows the programmer to reuse code rather than re-implement the same functionality for each web page. For example, if the data handling code wasn't split into its own separate functions, we would have to write the same database connection code and SQL queries in each of the functions that render a web page.
A large amount of research and a lot of painful first-hand experience of what can go wrong while developing web applications has made this book the most comprehensive resource on Flask available, so I sincerely hope that you will enjoy reading it.