All Posts

Comparison of new Python web frameworks

Comparison of new Python web frameworks

Python has been the go to language for building web services, right from quick-and-dirty RESTful APIs to full-fledged web applications that serve millions of users. If you have been dabbling in this area, you'd have probably used some of the most popular web frameworks already — Django, Flask, Falcon, Tornado, CherryPy, among others.

In the last few years, though, there have been many new kids on the block. These new frameworks have taken a fresh approach with focus on performance and expressiveness of the API. Here's a comparision of new web frameworks in Python that you should consider for your next side project.

You might also want to check out DeepSource's static analysis for Python, that detects 550+ bug risks, anti-patterns, and security vulnerabilities in your Python code.

1. Sanic


Sanic dubs itself as a web server and web framework that's written to go fast. It allows the usage of the `async` / `await` syntax added in Python 3.5, which makes your code non-blocking and speedy. Sanic makes use of `uvloop` and `ujson` to help with performance, but those packages are optional.


pip install sanic

Hello world example

from sanic import Sanic
from sanic.response import json

app = Sanic()

async def test(request):
    return json({'hello': 'world'})

if __name__ == '__main__':'', port=8000)

Sanic on GitHub »

2. Starlette

Starlette is a lightweight [ASGI]( framework which is ideal for building high performance `asyncio` services, designed to be used either as a complete framework, or as an ASGI toolkit. With some batteries included, it has support for WebSockets, GraphQL, in-process background tasks, and a test client built on [requests](


pip install starlette

Hello world example

from starlette.applications import Starlette
from starlette.responses import JSONResponse
import uvicorn

app = Starlette(debug=True)

async def homepage(request):
    return JSONResponse({'hello': 'world'})

if __name__ == '__main__':, host='', port=8000)

Starlette on GitHub »

3. Masonite


Masonite is a developer centric Python web framework that strives for an actual batteries included developer tool with a lot of out of the box functionality with an extremely extensible architecture. It has a simple and expressive routing engine, a simple migration system that removes the "magic" and finger crossing of migrations, and a great Active Record style ORM called Orator.


pip install masonite-cli

Masonite on GitHub »

4. FastAPI


FastAPI is a modern, high-performance, web framework for building APIs with Python 3.6+ based on standard Python type hints. It is built on top of Starlette, and is one of the fastest Python frameworks available. Based on, and fully compatible with, the open standards for APIs — [OpenAPI]( (previously known as Swagger) and [JSON Schema](


pip install fastapi

Hello world example

from fastapi import FastAPI

app = FastAPI()

def read_root():
    return {"Hello": "World"}

FastAPI on GitHub »

5. Responder


Also based on Starlette, Responder's primary concept is to bring the niceties that are brought forth from both Flask and Falcon and unify them into a single framework. It has a production static file server is built-in, automatic gzipped-responses, native GraphQL support, and a built-in testing client that uses [requests](


pip install responder

Hello world example

import responder

api = responder.API()

async def greet_world(req, resp, *, greeting):
    resp.text = f"{greeting}, world!"

if __name__ == '__main__':

Responder on GitHub »

6. Molten


Molten is a minimal, extensible, fast and productive framework for building HTTP APIs with Python. Molten can automatically validate requests according to predefined schemas, ensuring that your handlers only ever run if given valid input. Molten also has support for a function-based middleware, dependency injection, and includes the `molten.contrib` package which contains various functionality commonly required by APIs in the real world such as configuration files, Prometheus metrics, request IDs, sessions, SQLAlchemy, templating, websockets and more.


pip install molten

Hello world example

from molten import App, Route

def hello(name: str) -> str:
    return f"Hello {name}!"

app = App(routes=[Route("/hello/{name}", hello)])

Molten on GitHub »

7. Japronto

Japronto is a screaming-fast, scalable, asynchronous Python 3.5+ HTTP toolkit integrated with pipelining HTTP server based on uvloop and picohttpparser. It's targeted at speed enthusiasts, people who like plumbing and early adopters. There is no new project development happening at the moment, but it's not abandoned either.


pip install japronto

Hello world example

from japronto import Application

def hello(request):
    return request.Response(text='Hello world!')

app = Application()
app.router.add_route('/', hello)

Japronto on GitHub »

8. Klein

Klein is a micro-framework for developing production-ready web services with Python. It is 'micro' in that it has an incredibly small API similar to Bottle and Flask. It is not 'micro' in that it depends on things outside the standard library. This is primarily because it is built on widely used and well tested components like Werkzeug and Twisted.


pip install klein

Hello world example

from klein import run, route

def home(request):
    return 'Hello, world!'

run("localhost", 8080)

Klein on GitHub »

9. Quart


Quart is a Python ASGI web microframework. It is intended to provide the easiest way to use asyncio functionality in a web context, especially with existing Flask apps. This is possible as the Quart API is a superset of the Flask API. Quart aims to be a complete web microframework, as it supports HTTP/1.1, HTTP/2 and websockets.


pip install quart

Hello world example

rom quart import Quart, websocket

app = Quart(__name__)

async def hello():
    return 'hello'

async def ws():
    while True:
        await websocket.send('hello')

Quart on GitHub »

10. BlackSheep


BlackSheep is an asynchronous web framework to build event based, non-blocking Python web applications. It is inspired by Flask and ASP.NET Core. BlackSheep supports automatic binding of values for request handlers, by type annotation or by conventions. It also supports dependency injection, and implements strategies to handle authentication and authorization using external libraries.


pip install blacksheep

Hello world example

from datetime import datetime
from blacksheep.server import Application
from blacksheep.server.responses import text

app = Application()

async def home(request):
    return text(f'Hello, World! {datetime.utcnow().isoformat()}')

from datetime import datetime
from blacksheep.server import Application
from blacksheep.server.responses import text

app = Application()

async def home(request):
   return text(f'Hello, World! {datetime.utcnow().isoformat()}')

BlackSheep on GitHub »

11. Cyclone

Cyclone is a web server framework that implements the Tornado API as a Twisted protocol. The idea is to bridge Tornado's elegant and straightforward API to Twisted's Event-Loop, enabling a vast number of supported protocols. This combination provides the ground for building up hybrid servers capable of handling HTTP very efficiently while also serve or use e-mail, ssh, sip, irc, etc, all concurrently.


pip install cyclone

Cyclone on GitHub »

Get started with DeepSource

DeepSource is free forever for small teams and open-source projects. Start analyzing your code in less than 2 minutes.


Read product updates, company announcements, how we build DeepSource, what we think about good code, and more.

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.