Skip to main content

Muffin is a fast, simple and asyncronous web-framework for Python 3 (asyncio, trio)

Project description

https://raw.github.com/klen/muffin/develop/docs/static/logo-h200.png

Muffin – is a fast, lightweight and asyncronous ASGI web-framework for Python 3.

Tests Status Documentation Status PYPI Version Python Versions

Features

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.7 and newer (PyPy-3.7 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.

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?

  1. First we imported the muffin.Application class. An instance of this class will be our application.

  2. Next we create an instance of this class.

  3. We then use the muffin.Application.route decorator to tell Muffin what URLs should trigger our handler function.

  4. 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)

Tests Status PYPI Version

Muffin-Session

Signed Cookie-Based HTTP sessions (asyncio/trio/curio)

Tests Status PYPI Version

Muffin-OAuth

Work with OAuth (authorization, resources loading) (asyncio/trio/curio)

Tests Status PYPI Version

Muffin-Sentry

Sentry integration (asyncio/trio/curio)

Tests Status PYPI Version

Muffin-Peewee

Peewee support (SQL, ORM) (asyncio/trio/curio)

Tests Status PYPI Version

Muffin-Babel

Localization support (asyncio/trio/curio)

Tests Status PYPI Version

Muffin-Databases

Work with SQL databases (asyncio only)

Tests Status PYPI Version

Muffin-Mongo

Work with Mongo DB (asyncio only)

Tests Status PYPI Version

Muffin-REST

The package provides enhanced support for writing REST APIs (asyncio/trio/curio)

Tests Status PYPI Version

Muffin-Redis

Redis support

Tests Status PYPI Version

Muffin-Admin

Automatically build Admin UI

Tests Status PYPI Version

Muffin-Prometheus

Prometheus metrics exporter

Tests Status PYPI Version

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 (See 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

muffin-0.86.0.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

muffin-0.86.0-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

Details for the file muffin-0.86.0.tar.gz.

File metadata

  • Download URL: muffin-0.86.0.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for muffin-0.86.0.tar.gz
Algorithm Hash digest
SHA256 d4073846ef11252adb05ce5adc92d029011e1937b5d5a861621e7a0a46a7f014
MD5 3a3775877ece46bc0d881e2a81fecca2
BLAKE2b-256 63dc7b59c74e67014212a1fd5f0144dd583ff17e8d123fd6d5f27590b8b5112e

See more details on using hashes here.

File details

Details for the file muffin-0.86.0-py3-none-any.whl.

File metadata

  • Download URL: muffin-0.86.0-py3-none-any.whl
  • Upload date:
  • Size: 14.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for muffin-0.86.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e9709666e060b21041afed90c53b61ee139fae7010a22f75b68cd995ed4b44c5
MD5 62d4f0377a63fb95ea0fbf6d23bf8950
BLAKE2b-256 1de784402484efc95d60cb92183eeebefc6bc582aec80f9ebb9db590fdd12018

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page