3 ms·
Why Choose Flask over FastAPI
- bayesian_horse 5y agoDid I miss it or did that article not give any real reason for choosing Flask? I don't want to bash on Flask, but I really don't know a good reason for choosing Flask in the first place. The only reason may be that it is slightly simpler to use as long as the usecase is very simple. For a minimal microservice, something based on asyncio really is preferable. Flask doesn't do async IO. I don't really care if it is as fast as Go or node, but non-blocking matters. On the other hand, what Django brings to the table also matters. I much prefer using the kitchen sink offered by Django rather than bolting on bits and pieces to a Flask or FastAPI solution. One notable exception is OctoPrint, which uses Flask. It's designed to run on Raspberry Pis with limited resources. Maybe it would be better off with FastAPI now but it started on Flask when FastAPI didn't exist, and Django would probably have been too heavy and opinionated in that scenario.
- aradox66 5y ago"The title is just a note saying why you should not go about writing articles that way. The article is deliberately mistitled and put en relief the point that you should not compare Flask to FastAPI nor compare FastAPI to Flask. Both serve different purposes."
- bayesian_horse 5y agoAnd I still don't get what purpose Flask is the best choice for currently...
- okl 5y agoYou fell into the same trap that the author points out: Flask, FastAPI and Django are tools with different scopes for different purposes. If you want to compare FastAPI, compare it with Flask-RESTx or Django-REST, for example. If you want to compare Flask, compare it with Starlette, for example. asyncio won't do much for you if your application is CPU-bound. (Admittedly, that's usually not the case with network services)
- bayesian_horse 5y agoI'm not pedantic enough to spell out that there are gazillions of ways to do REST in Flask. And Flask as a microframework for websites seems a lot less useful for me because I'd need to bolt on a lot of stuff to make it more useful.