Muffin – fast, lightweight, and asynchronous ASGI web framework for Python 3.11+.
Why 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.
Key Features
- ASGI compatible
- Competitive performance ([Benchmarks](http://klen.github.io/py-frameworks-bench/))
- 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
Installation
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]Dependencies
These packages will be installed automatically:
- ASGI-Tools – ASGI toolkit
- Modconfig – hierarchical configuration manager
Quickstart
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.
Plugins
Muffin has a rich ecosystem of plugins:
- [muffin-jinja2](https://github.com/klen/muffin-jinja2) – Jinja2 templates (asyncio/trio/curio)
- [muffin-session](https://github.com/klen/muffin-session) – Signed cookie-based HTTP sessions
- [muffin-oauth](https://github.com/klen/muffin-oauth) – OAuth integration
- [muffin-sentry](https://github.com/klen/muffin-sentry) – Sentry error tracking
- [muffin-peewee](https://github.com/klen/muffin-peewee-aio) – Peewee ORM integration
- [muffin-babel](https://github.com/klen/muffin-babel) – i18n support
- [muffin-databases](https://github.com/klen/muffin-databases) – SQL database support
- [muffin-mongo](https://github.com/klen/muffin-mongo) – MongoDB integration
- [muffin-rest](https://github.com/klen/muffin-rest) – REST API utilities
- [muffin-redis](https://github.com/klen/muffin-redis) – Redis integration
- [muffin-admin](https://github.com/klen/muffin-admin) – Auto-generated admin UI
- [muffin-prometheus](https://github.com/klen/muffin-prometheus) – Prometheus metrics exporter
See each repo for usage and installation instructions.
Benchmarks
Performance comparisons are available at: http://klen.github.io/py-frameworks-bench/
Bug tracker
Found a bug or have a feature request? Please open an issue at: https://github.com/klen/muffin/issues
Contributing
Contributions are welcome! Please see [CONTRIBUTING.md](https://github.com/klen/muffin/blob/develop/CONTRIBUTING.md) for guidelines.
License
Muffin is licensed under the MIT license.
Credits
Muffin > 0.40 (completely rewritten on ASGI)
Muffin < 0.40 (based on AIOHTTP_)