What is Flask ?
Flask is a web framework. This means flask provides you with tools, libraries and technologies that allow you to build a web application. This web application can be some web pages, a blog, a wiki or go as big as a web-based calendar application or a commercial website.
Flask is part of the categories of the micro-framework. Micro-framework are normally framework with little to no dependencies to external libraries.This has pros and cons. Pros would be that the framework is light, there are little dependency to update and watch for security bugs, cons is that some time you will have to do more work by yourself or increase yourself the list of dependencies by adding plugins. In the case of Flask, its dependencies are:
- Werkzeug a WSGI utility library
- jinja2 which is its template engine
Companies that use Flask
There are over 25 big companies that use Flask, some of them are:
- Netflix
- Lyft
- Trivago
- Uber
Pros and Cons of Flask
Pros:
- Simpler Development. If you understand Python well, then you’ll be able to move around and contribute to a Flask application pretty easily. It’s less opinionated so fewer standards to learn.
- Flexibility. There are very few parts of Flask that cannot be easily and safely altered because of its simplicity and minimality.
- Performance. You can think about a micro framework being slightly more “low-level” than something like Django. There are fewer levels of abstraction between you and the database, the requests, the cache, etc. So performance is inherently better from the start.
- Modularity. Modular code provides a huge number of benefits. With Flask, you have the ability to create multiple Flask applications or servers, distributed across a large network of servers, each with specific purposes. This creates more efficiency, better testability, and better performance.
Cons:
- Bad developers will write worse code. I like to assume that companies are not hiring “bad developers”, but in the case that you have a younger developer training or used to have developers contributing lower quality code, then it will amplify the bad code. It’s easier to draw within the lines of a large, standardized framework like Django.
- Fewer tools. You don’t have a full toolset underneath you. So you may need to build more on your own or search out extensions/libraries from the community.
- Community. The monoliths provide such a large toolset, focused on providing solutions for a larger set of use cases out of the box, that they typically have a larger community. This means more eyes on the code, more code reviews, and better-tested core code. This is a little bit of a generalization though.
Flask Alternatives
- Django: Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design.
- Tornado: By using non-blocking network I/O, Tornado can scale to tens of thousands of open connections, making it ideal for long polling, WebSockets, and other applications that require a long-lived connection to each user.
- ExpressJS: Express is a minimal and flexible node.js web application framework, providing a robust set of features for building single and multi-page, and hybrid web applications.
- Node.js: Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.
- React: Lots of people use React as the V in MVC. Since React makes no assumptions about the rest of your technology stack, it’s easy to try it out on a small feature in an existing project.
Conclusion
Choose Flask if you have a small or mid-sized project that has unique requirements and requires custom components. Flask is especially good for prototyping.
0 Comments