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

  • ASGI compatible;

  • Support Asyncio and Trio libraries;

  • Parse ASGI scope, get url, headers, cookies, read a request’s data/json/form-data

  • Send HTTP (text, html, json, stream, file, http errors) responses

  • Work with WebSockets

Docs are available at https://klen.github.io/muffin/. Pull requests with documentation enhancements and/or fixes are awesome and most welcome.

Installation

The Muffin should be installed using pip:

pip install muffin

We recommend using the latest version of Python. Muffin supports Python 3.7 and newer.

Dependencies

These distributions will be installed automatically when installing Muffin.

Quickstart

Example “Hello User” with the Muffin:

import muffin


app = muffin.Application('example')


@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. The first argument is the name of the application.

  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

The list of some Muffin plugins (please make PR if you want to provide more):

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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

muffin-0.50.3-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: muffin-0.50.3-py3-none-any.whl
  • Upload date:
  • Size: 14.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.9.0

File hashes

Hashes for muffin-0.50.3-py3-none-any.whl
Algorithm Hash digest
SHA256 73edb6709b83c750f77ddec2790d1895288906bd1d8673a0e755be6ef97a64ea
MD5 c93b3ae0551d0b96e2f4d629cc1c0845
BLAKE2b-256 337da21af1a123c3d68f793c873d70e186740033c93793d56a1a45be29444eca

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