Skip to main content

Lightweight ASGI framework for Python

Project description

blunt-logo

✨ The little ASGI framework that shines. ✨


Package version Supported Python Version


Documentation: https://ndugram.github.io/blunt Source Code: https://github.com/ndugram/blunt


Blunt

Blunt is a lightweight ASGI framework/toolkit, which is ideal for building async web services in Python.

It is production-ready, and gives you the following:

  • A lightweight, low-complexity HTTP web framework.
  • Auto-generated API documentation (Swagger UI & ReDoc).
  • Middleware support (CORS, Timing, and more).
  • Static files and template rendering.
  • Path parameters and query string handling.
  • Type hints and clean API.
  • Few hard dependencies.
  • Compatible with asyncio backends.

Installation

$ pip install blunt

You'll also want to install an ASGI server, such as uvicorn:

$ pip install uvicorn

Example

from blunt import Blunt, Route
from blunt.responses import JSONResponse


async def homepage(request):
    return JSONResponse({'hello': 'world'})


routes = [
    Route("/", endpoint=homepage)
]

app = Blunt(debug=True, routes=routes)

Then run the application using Uvicorn:

$ uvicorn main:app

Auto Documentation

Once running, visit:

  • /docs — Swagger UI
  • /redoc — ReDoc
  • /openapi.json — OpenAPI schema

Dependencies

Blunt requires anyio, and the following are optional:

  • pydantic - Required for data validation and response models.
  • jinja2 - Required if you want to use templates.

Framework or Toolkit

Blunt is designed to be used either as a complete framework, or as an ASGI toolkit. You can use any of its components independently.

from blunt.responses import PlainTextResponse


async def app(scope, receive, send):
    assert scope['type'] == 'http'
    response = PlainTextResponse('Hello, world!')
    await response(scope, receive, send)

Run the app application in example.py:

$ uvicorn example:app
INFO: Started server process [11509]
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)

Run uvicorn with --reload to enable auto-reloading on code changes.


Blunt is BSD licensed code.
Designed & crafted with care.

— ⭐️ —

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

blunt-0.0.4.tar.gz (24.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

blunt-0.0.4-py3-none-any.whl (28.0 kB view details)

Uploaded Python 3

File details

Details for the file blunt-0.0.4.tar.gz.

File metadata

  • Download URL: blunt-0.0.4.tar.gz
  • Upload date:
  • Size: 24.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for blunt-0.0.4.tar.gz
Algorithm Hash digest
SHA256 76f7f1cb8e92d922551878ee04a71a9eceef43ab6d3f0565ab2bc81f58e90b38
MD5 03ba2ac819a66038983e85cc7634f826
BLAKE2b-256 f578e661a3676e0eace115d4314ff09df3fd4832f91631f80b10eff6fa666494

See more details on using hashes here.

File details

Details for the file blunt-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: blunt-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 28.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for blunt-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 454fbb6d24f790f5bb5e8c0831cb9fd195cb1ff5ad350bf1a8bad01077e7f968
MD5 d76a910010c123159e1f62f9996da359
BLAKE2b-256 b60de964fef42a5edc341fa4c1dfb8b37f43d582d259d2f2c44bdd740f039d5e

See more details on using hashes here.

Supported by

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