Why using Flask, fastAPI when there is Streamlit?

Hi there,
I am a student in data science, and I don’t understand why we would use a framework like Flask ou FastAPI without any UI when we can use Streamlit with a beautiful and simple UI ? Are they two things totally different ?

When I want to show a final user how to use a model I use only streamlit, I don’t even know how to use Flask…

Many thanks,

Hi @Maxime_tut -

The short answer is, they are all different projects with different goals :slight_smile:

A longer answer might be…

Flask is a barebones web framework, which was a reaction to the “everything included” nature of Django. Not everyone needed a login functionality, a database data model and all the other things that came along with Django’s original use-case (a content-management system if I’m not mistaken, similar in nature to the Wordpress project). So Flask came along and let you start with the absolute minimum you needed to serve different pages/endpoints (i.e. different urls), and then you can add in a database piece or whatever else you wanted.

FastAPI is a reimagining of Flask in some ways, recognizing that for people who only want to create an API (but not serve web pages), that perhaps there’s a more efficient way of creating APIs with a purpose-built package. So FastAPI aims to be performance-faster, easier to code for the API use case faster, implements API-specific things such as OpenAPI and JSON schemas, etc.

Then there’s Streamlit. Streamlit, in its current state, only allows for a single-url style app. You cannot make API requests (i.e. GET/POST/PUT, etc.) like you can with Flask or Fast API, and the focus tends to be around data apps instead of computers talking to other computers like API use-cases generally are. But because Streamlit is focusing on the data app use case, it comes with a lot of conveniences for human interaction with the app without all the extra/difficult functionality of Django/Flask/Fast API.

Of course, as each project continues over time, people figure out new and interesting ways to use them. So in one sense, lots of projects tend to converge towards what people want to do vs. being completely separate functionalities. But that’s one of the best parts of open-source, that besides being monetary free, you are free to pick and choose which package(s) give you the best solution for your specific use.