Welcome to Muffin’s documentation!#

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

Tests Status Documentation Status PYPI Version Python Versions

Features#

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.

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!

Table of Contents#