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.0.tar.gz (23.7 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.0-py3-none-any.whl (26.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: blunt-0.0.0.tar.gz
  • Upload date:
  • Size: 23.7 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.0.tar.gz
Algorithm Hash digest
SHA256 b9b9224170e986e6fbb9fefab8b3549f7d3ba50a25539a153b38f645aed8a222
MD5 934f363173f4394de141b5b381396eb5
BLAKE2b-256 b5ec87dbba99556752f2d2378dff558d1963252b440585c59cd0851d6dcfc60d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blunt-0.0.0-py3-none-any.whl
  • Upload date:
  • Size: 26.6 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 df9ca5a0b8b99f3e893d25c7a2929391a30a8001df8e0349adcc132eb5eb46ba
MD5 4cbe521f217862736b6ee909021605ac
BLAKE2b-256 956effc8002c343a5e521f7e484576a67bd0852fd7c63c5f233fc309a7f0499b

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