Lightweight ASGI framework for Python
Project description
✨ The little ASGI framework that shines. ✨
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
asynciobackends.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file blunt-0.0.1.tar.gz.
File metadata
- Download URL: blunt-0.0.1.tar.gz
- Upload date:
- Size: 14.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce2a9238c96141cefae4585f54cb2633c9690c8965c57223bff11b96e42cd0a5
|
|
| MD5 |
f0d59c7d34ae6974c303b55f196231a8
|
|
| BLAKE2b-256 |
098773f5462232741009d1e43e86a572ca9232341cde8f7aae5b66ecb2201956
|
File details
Details for the file blunt-0.0.1-py3-none-any.whl.
File metadata
- Download URL: blunt-0.0.1-py3-none-any.whl
- Upload date:
- Size: 15.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2f31191ac8c63bd4eeecaa3ce253477bdbf6297b313eb908dfdfa272ada2736e
|
|
| MD5 |
cf96609cde7f22f9cef6a2e40d5215c8
|
|
| BLAKE2b-256 |
a2a3371179cc73b26a7a64bdda0966bcf46b8bca44dfbf36e0a3008b30f67d46
|