Posts

Showing posts from June, 2021

Moving from Flask to FastAPI

Image
  Python is one of the most popular programming languages. From scripting to API development to machine learning -- Python has a footprint. Its popularity is fueled by the tools it offers. Flask, a web framework, is one such tool, which is popular amongst the machine learning community. It's also widely used for API development. But there's a new framework on the rise:   FastAPI . Unlike Flask, FastAPI is an ASGI (Asynchronous Server Gateway Interface) framework. On par with Go and NodeJS, FastAPI is one of the fastest Python-based web frameworks. This article, which is aimed for those interested in moving from Flask to FastAPI, compares and contrasts common patterns in both Flask and FastAPI. FastAPI vs Flask FastAPI was built with these three main concerns in mind: Speed Developer experience Open standards You can think of FastAPI as the glue that brings together  Starlette ,  Pydantic ,  OpenAPI , and  JSON Schema . Under the hood, FastAPI uses Pydantic for data validation a