![]() Well, in this boilerplate, there's one blueprint core serving as a base and more can be added later as shown below:Įnter fullscreen mode Exit fullscreen mode You can (hackily) separate them, but wouldn’t it be nice to have something that groups related views, templates, models, and forms? Blueprints! They are a great way to modularly compose Flask applications, which will help scale up projects. In a normal project, the number of views, and templates, and models, and forms, etc. Hence, we are making use of factory pattern inside this boilerplate project to make our lives a bit easier. The reason why the Application Factory is so important has to do with something called Flask's Application Context. The Flask Application Factory refers to a common pattern for solving this dilemma. Separating logic between modules means we would be importing this app object all over the place, eventually leading to problems like circular imports. This seems tricky with Flask at first glance because our app depends on an app object that we create via app = Flask(_name_). Well-structured web apps separate logic between files and modules, typically with separation of concerns in mind. Let's talk a bit more about the concepts here: On a high level, flask application can be created even with a single page or via a factory pattern method. The choice of keeping files in different folders is dependent on an individual/team/project type. The following are some of the points in building up an efficient app explained concerning this flask boilerplate.įlask applications generally have many variations in their folder structure. When we start a project from scratch, especially the backend services, there are some basic functionalities that it should possess. Hence, I decided to make this very basic lightweight boilerplate available for the community while I figured out the structure working on multiple live projects in the past. When I started working on a flask application for the first time, I had a tough time figuring out the correct structure and packages to achieve the necessities of my flask app. But you can surely customize it based on your need □ ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |