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,

2 Likes

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.

Best,
Randy

15 Likes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.