Express.js vs Flask
When comparing Express.js vs Flask, the Slant community recommends Express.js for most people. In the question“What are the best backend web frameworks?” Express.js is ranked 3rd while Flask is ranked 7th. The most important reason people chose Express.js is:
Setting up a new Express project is very easy. It consists of installing a handful of libraries through NPM run a single `npm install` and everything is ready to go.
Specs
Ranked in these QuestionsQuestion Ranking
Pros
Pro Setting up is very easy
Setting up a new Express project is very easy. It consists of installing a handful of libraries through NPM run a single npm install
and everything is ready to go.
Pro Great routing API
Express' extremely powerful routing API allows developers to do tasks ranging from building a REST API to building the routes for a simple web app and then take it to the next level by using route parameters and query strings.
Pro Great for beginner Node.js programmers
With a little learning curve, it is a good choice for new NodeJS developers to get started quickly. Express boasts great, thorough documentation.
Pro Express.js is in the Node.js Foundation Incubator Program
Node.js Foundation
Announcement here
The Node.js Foundation is a Collaborative Project at The Linux Foundation. Linux Foundation Collaborative Projects are independently funded software projects that harness the power of collaborative development to fuel innovation across industries and ecosystems.
Pro Relatively mature
Being a somewhat old Node.js web app framework and being one of the most widely used frameworks, Express.js has matured quite a lot during all that time. It's more stable than its competitors and a huge community backing it.
Pro Support for a lot of plugins
Express takes advantage of Node's NPM to distribute and install countless plugins made by third parties which solve almost anything a developer would want to do with Express.
Pro Has the largest userbase
It's by far the most popular framework for node.
Pro Great supportive community
Express has a big community with a lot of guides and tutorials written about it by developers that have been using it for quite some time.
Pro Good Oauth/Facebook integration with connect module
You can easily add oAuth integration/social logins to your next web app without much hassle, using this authentication middleware for connect.
Pro Has detailed information
Very simple and fast.
Pro Lightweight
Pro Massive ecosystem of middleware
If you have not already checked out the Express.js ecosystem of middleware, you should.
Pro Minimalist without losing power
Flask is very easy to get up and going, with vanilla HTML or with bootstrap pieces. It doesn't take much lines of Python to load Flask to get headers working, etc, and since it's all modular you don't have to have something you don't want in your application.
Pro Lots of resources available online
Flask is one of the most popular Python web frameworks, if not the most popular one. As such, there's plenty of guides, tutorials, and libraries available for it. A large number of important Python libraries, such as SQLAlchemy have libraries for Flask, which add valuable bindings to make the development process and the integration between these libraries and Flask as easy as possible.
Pro Extremely easy to build a quick prototype
Even though it's pretty minimalistic out of the box, Flask still provides the necessary tools to build a quick prototype for a web app right after a fresh install. With all the main components pretty much packed in the flask
package, building a simple web app in a single Python file is as easy as it gets.
Pro Very flexible
Flask gives developers a lot of flexibility in how they develop their web applications.
For example, the choice of not having an ORM, but instead choosing one suited to the task, or another area where Flask gives a lot of options to developers is the templating. They can use Jinja2, Flask's default templating language or choose from a number of different templating languages they desire.
Pro Great documentation
The official documentation is very thorough and complete. Everything is explained in-depth and followed by extremely well-explained tutorials that tackle real-world problems.
Pro Able to use ORM or "true SQL"
Cons
Con No single recommended way of doing something
Express considers itself to be a "minimalistic unopinionated framework", it basically lets the developer determine how their project will be organized. On one hand, this gives anyone terrific power and flexibility to use any library they want for a certain task and to organize their project structure however they want. But on the other hand, there's no single recommended way of organizing things, which can be a trap for beginners and experienced developers alike and result in unmaintainable projects.
Con Not async-friendly
Flask is explicitly not designed to handle async programming.
Con Setting up a large project requires some previous knowledge of the framework
Setting up a large project with Flask is not that easy considering how there's no "official" way of doing it. Blueprints are a useful tool in this regard but require some additional reading and are a bit tricky to get right for a beginner.
The lack of some defaults can also be problematic. Having to choose between different libraries for a certain task is never easy, especially if you have never worked with Flask before.
Con Threadlocals and globals used everywhere
The default way of creating applications in flask makes it hard to use reusable and clean code.
Con HTML-oriented, not API-oriented
Not necessarily designed for making APIs, though that is possible