Muffin is a fast, simple and asyncronous web-framework for Python 3 (asyncio, trio, curio)
Project description
Muffin – is a fast, lightweight and asyncronous ASGI web-framework for Python 3.
Features
ASGI compatible;
All async python libraries are supported (Asyncio, Trio, Curio);
Send HTTP (text, html, json, stream, file, http errors) responses
Support WebSockets, Server Side Events
Docs are available at https://klen.github.io/muffin/. Pull requests with documentation enhancements and/or fixes are awesome and most welcome.
Installation
We recommend using the latest version of Python. The library supports Python 3.8 and newer (PyPy-3.9+ are supported too).
Muffin should be installed using pip:
pip install muffin
The command will install minimal configuration.
To install Muffin with gunicorn, uvicorn, uvloop, httptools use the command:
$ pip install muffin[standard]
Dependencies
These distributions will be installed automatically when installing Muffin.
ASGI-Tools - ASGI Toolkit
Modconfig - Simple hierarchic configuration manager
Quickstart
Example “Hello User” with the Muffin:
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()}!'
What did that code do?
First we imported the muffin.Application class. An instance of this class will be our application.
Next we create an instance of this class.
We then use the muffin.Application.route decorator to tell Muffin what URLs should trigger our handler function.
The function returns the message we want to display in the user’s browser.
Save the script as example.py and run it using Uvicorn (or another ASGI server):
$ uvicorn example:app
Open http://localhost:8000, http://localhost:8000/hello/username in your browser. Enjoy!
Plugins overview
The list of some Muffin plugins (please make PR if you want to provide more):
Muffin-Jinja2
Jinja2 templates (asyncio/trio/curio)
Muffin-Session
Signed Cookie-Based HTTP sessions (asyncio/trio/curio)
Muffin-OAuth
Work with OAuth (authorization, resources loading) (asyncio/trio/curio)
Muffin-Sentry
Sentry integration (asyncio/trio/curio)
Muffin-Peewee
Peewee support (SQL, ORM) (asyncio/trio/curio)
Muffin-Babel
Localization support (asyncio/trio/curio)
Muffin-Databases
Work with SQL databases (asyncio only)
Muffin-Mongo
Work with Mongo DB (asyncio only)
Muffin-REST
The package provides enhanced support for writing REST APIs (asyncio/trio/curio)
Muffin-Redis
Redis support
Muffin-Admin
Automatically build Admin UI
Muffin-Prometheus
Prometheus metrics exporter
Benchmarks
You could find some tests here: http://klen.github.io/py-frameworks-bench/
Bug tracker
If you have any suggestions, bug reports or annoyances please report them to the issue tracker at https://github.com/klen/muffin/issues
Contributing
Development of The Muffin happens at: https://github.com/klen/muffin
Contributors
Muffin > 0.40 (completelly rewriten from scratch)
Muffin < 0.40 (based on AIOHTTP)
License
Licensed under a MIT license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file muffin-0.98.2.tar.gz
.
File metadata
- Download URL: muffin-0.98.2.tar.gz
- Upload date:
- Size: 15.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.0 CPython/3.10.6 Linux/5.15.0-1037-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e1dce29931e2fc021e650f4b2ade165b7c4e414ecd2928c0102ddf34f7ef5ea5 |
|
MD5 | b99b703639e7fa43ba61726221273e49 |
|
BLAKE2b-256 | 7d1ccb2781ff170eff74779ad756039b0f96c2ad43a7988748a3c4046b8bfe38 |
File details
Details for the file muffin-0.98.2-py3-none-any.whl
.
File metadata
- Download URL: muffin-0.98.2-py3-none-any.whl
- Upload date:
- Size: 15.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.0 CPython/3.10.6 Linux/5.15.0-1037-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4315b8e82562e4e78b4cadfa3fa3e390147d2f50c5dd9d81a948f5ea4c840eba |
|
MD5 | 241390bfd926ea1860fb8aac77f0bb9d |
|
BLAKE2b-256 | 5dbc4e91f75a28097c5a2720c3cd5396a0d6705f847e994acbf9fb5c4f01b23f |