Muffin – fast, lightweight, and asynchronous ASGI web framework for Python 3.11+.
Documentation: https://klen.github.io/muffin
Muffin combines the simplicity of microframeworks with native ASGI performance, supporting multiple async libraries (Asyncio, Trio, Curio) out of the box. Its rich plugin ecosystem makes building modern web applications pleasant and efficient.
- ASGI compatible
- Competitive performance (Benchmarks)
- Supports Asyncio, Trio, and Curio
- Multiple response types: text, HTML, JSON, streams, files, SSE, WebSockets
- First-class plugin system for templating, databases, auth, and more
Muffin requires Python 3.11 or newer. We recommend using the latest stable Python.
Install via pip:
$ pip install muffinFor the standard installation with gunicorn, uvicorn, uvloop, httptools:
$ pip install muffin[standard]These packages will be installed automatically:
- ASGI-Tools – ASGI toolkit
- Modconfig – hierarchical configuration manager
Create a simple "Hello User" app:
import muffin
app = muffin.Application()
@app.route('/', '/hello/{name}')
async def hello(request):
name = request.path_params.get('name', 'world')
return f'Hello, {name.title()}!'Save this as example.py and run:
$ uvicorn example:appVisit http://localhost:8000 or http://localhost:8000/hello/username in your browser.
Muffin has a rich ecosystem of plugins:
- muffin-jinja2 -- Jinja2 templates (asyncio/trio/curio)
- muffin-session -- Signed cookie-based HTTP sessions
- muffin-oauth -- OAuth1/OAuth2 integration
- muffin-sentry -- Sentry error tracking
- muffin-peewee-aio -- Peewee ORM integration with async support
- muffin-babel -- Localization with Babel
- muffin-databases -- Async support for a range of databases
- muffin-mongo -- MongoDB integration
- muffin-redis -- Redis integration
- muffin-rest -- REST helpers
- muffin-apiclient -- Support for external APIs
- muffin-grpc -- GRPC support
- muffin-kafka -- Kafka integration
- muffin-admin -- Admin interface
- muffin-prometheus -- Prometheus metrics exporter
See each repo for usage and installation instructions.
Performance comparisons are available at: http://klen.github.io/py-frameworks-bench/
Found a bug or have a feature request? Please open an issue at: https://github.com/klen/muffin/issues
Muffin is licensed under the MIT license.
Muffin > 0.40 (completely rewritten on ASGI)
Muffin < 0.40 (based on AIOHTTP_)
