DEV Community

Victor Neo 👩‍💻
Victor Neo 👩‍💻

Posted on • Originally published at cheshire.io on

ASGI Frameworks for Python Are Here

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 sincePEP 333 in 2003, and its update 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 (Asynchronous Server Gateway Interface).

Major web frameworks are currently working to go async, including Django,which is a major effort itself given the size of the framework. Flask,which uses Werkzeug 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 are helpful, it is still best to benchmark it against your own use cases.

TechEmpower Benchmarks Round 19

TechEmpower Benchmarks Round 19:
ASGI-based web frameworks perform much better than their WSGI-only counterparts

Try an ASGI-Supported Web Framework Today

If you are looking for a Django-like experience for a full web framework,FastAPI would offer the closest experience. There’s full support for Pydantic, which makes the experience more pure Python than to learn a new framework-specific API.

FastAPI Logo

FastAPI is your best choice for a full web framework

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

  • Quart offers full-API compatibility with Flask, and should be the first place where you start
  • Vibora has an API inspired by Flask with an obsession for speed
  • Sanic 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()
Quart’s Flask-Compatible API

If you are looking for an ASGI framework/toolkit , Starlette 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 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

Starlette, an ASGI Framework / Toolkit

If you try any of the frameworks above, I will be happy to hear more about your explorations with them here or on Twitter.

Top comments (0)