ASGI Frameworks for Python Are Here
Tags: python, web, api, frameworks
Published: 2020-06-07 05:15:57

---
title: ASGI Frameworks for Python Are Here
published: true
date: 2020-06-06 17:01:00 UTC
tags: python, web, api, frameworks
canonical_url: https://cheshire.io/posts/06-06-2020-asgi-frameworks/
---

## ASGI, WSGI, and Python

Most popular Python web frameworks, such as Django and Flask, works with WSGI (Web Server Gateway Interface) under the hood, which has been around since[PEP 333](https://www.python.org/dev/peps/pep-0333/) in 2003, and its update [PEP 3333](https://www.python.org/dev/peps/pep-3333/) in 2010.

With the introduction of asyncio in Python 3 and `await` syntax in Python 3.5,the Python community finally has an easy way to do asynchronous programming. It was only a matter of time before steam would pick up for asynchronous support for web frameworks in the form of [ASGI](https://asgi.readthedocs.io/en/latest/specs/main.html) (Asynchronous Server Gateway Interface).

Major web frameworks are currently working to go async, including [Django](https://docs.djangoproject.com/en/dev/releases/3.1/),which is a major effort itself given the size of the framework. [Flask](https://flask.palletsprojects.com/en/1.1.x/),which uses [Werkzeug](https://github.com/pallets/werkzeug/issues/1322#issuecomment-601062396) internally, does not have ASGI support yet.

If you are building a new Python-based web project today, the new of ASGI web frameworks should be on your list for consideration; they “generally” perform faster than their WSGI-only counterparts for the same workload, and while [benchmarks](https://www.techempower.com/benchmarks/#section=data-r19&hw=cl&test=composite&l=zijzen-1r) are helpful, it is still best to  benchmark it against your own use cases.

![TechEmpower Benchmarks Round 19](https://cheshire.io/images/asgi/benchmarks.png)

<center><em><a href="https://www.techempower.com/benchmarks/#section=data-r19&amp;hw=cl&amp;test=composite&amp;l=zijzen-1r" target="_blank">TechEmpower Benchmarks Round 19</a>: <br>ASGI-based web frameworks perform much better than their WSGI-only counterparts</em></center>

## Try an ASGI-Supported Web Framework Today

**If you are looking for a Django-like experience** for a full web framework,[FastAPI](https://fastapi.tiangolo.com/) would offer the closest experience. There’s full support for [Pydantic](https://fastapi.tiangolo.com/features/#just-modern-python), which makes the experience more pure Python than to learn a new framework-specific API.

![FastAPI Logo](https://cheshire.io/images/asgi/fastapi.png)

<center><em><a href="https://fastapi.tiangolo.com/" target="_blank">FastAPI</a> is your best choice for a full web framework</em></center>

**If you are looking for a Flask-like experience** for a micro-web framework,you will be spoiled for options.

- [Quart](https://pgjones.gitlab.io/quart/index.html) offers full-API compatibility with Flask, and should be the first place where you start
- [Vibora](https://vibora.io/) has an API inspired by Flask with an obsession for speed
- [Sanic](https://sanic.readthedocs.io/en/latest/) is also inspired by Flask but has different design decisions from Vibora

```
from quart import Quart

app = Quart( __name__ )

@app.route('/')
async def hello():
return 'hello'

app.run()
```

<center><em>Quart’s <a href="https://pgjones.gitlab.io/quart/tutorials/quickstart.html" target="_blank">Flask-Compatible API</a></em></center>

**If you are looking for an ASGI framework/toolkit** , [Starlette](https://www.starlette.io/) will be the one to go for. It is lower level than the ones listed above as it is ultimately a toolkit, but you might find it useful for developing your own frameworks. [Starlette-Starter](https://github.com/victorneo/starlette-starter) is a boilerplate that I have built for my own API projects, which might be helpful for you if you are looking for a starting point for your own frameworks.

![Starlette Logo](https://cheshire.io/images/asgi/starlette.png)

<center><em><a href="https://pgjones.gitlab.io/quart/tutorials/quickstart.html" target="_blank">Starlette, an ASGI Framework / Toolkit</a></em></center>

If you try any of the frameworks above, I will be happy to hear more about your explorations with them here or on [Twitter](https://twitter.com/victorneo).