Opinionless ASGI Framework 🙌
Project description
asgify
Opinionless ASGI Framework 🙌
📦 Installation
Using pip
pip install asgify
Using uv (Recommended)
uv add asgify
From Source
git clone https://github.com/aprilahijriyan/asgify.git
cd asgify
pip install -e .
🚀 Showcase
HTTP Application Example
import json
from asgify.app import Asgify
from asgify.context import HTTPContext
from asgify.status import HTTP_200_OK, HTTP_201_CREATED, HTTP_404_NOT_FOUND, HTTP_STATUS_CODES
async def http_handler(ctx: HTTPContext):
# Get path and method
path = ctx.path
method = ctx.method
if path == "/" and method == "GET":
await ctx.start(HTTP_200_OK, {"content-type": "application/json"})
await ctx.end(json.dumps({"message": "Hello from asgify!"}).encode())
elif path.startswith("/users/") and method == "GET":
user_id = path.split("/users/")[-1]
page = ctx.params.get("page", "1")
await ctx.start(HTTP_200_OK, {"content-type": "application/json"})
await ctx.end(
json.dumps({"user_id": user_id, "page": page, "status": "active"}).encode()
)
elif path == "/api/data" and method == "POST":
# Read JSON body
body = b""
async for chunk in ctx.read_body():
body += chunk
data = json.loads(body.decode())
await ctx.start(HTTP_201_CREATED, {"content-type": "application/json"})
await ctx.end(json.dumps({"created": True, "data": data}).encode())
else:
await ctx.start(HTTP_404_NOT_FOUND, {"content-type": "text/plain"})
await ctx.end(HTTP_STATUS_CODES[HTTP_404_NOT_FOUND].encode())
app = Asgify(http=http_handler)
To run the HTTP server example above using uvicorn, save the code to a file (for example, showcase_http.py) and run the following command in your terminal:
uvicorn showcase_http:app
WebSocket Application Example
import json
from datetime import datetime
from asgify.app import Asgify
from asgify.context import WebSocketContext
from asgify.errors import ClientDisconnected
async def websocket_handler(ctx: WebSocketContext):
await ctx.accept()
await ctx.send_bytes("Welcome to asgify 🚀".encode())
while True:
try:
data = await ctx.receive_text()
print("<", data)
reply = json.dumps({"echo": data, "timestamp": datetime.now().isoformat()})
await ctx.send_text(reply)
print(">", reply)
except ClientDisconnected:
print("disconnected with client")
break
app = Asgify(websocket=websocket_handler)
To run the WebSocket server example above using uvicorn, save the code to a file (for example, showcase_websocket.py) and run the following command in your terminal:
uvicorn showcase_websocket:app
Testing with wscat:
❯ wscat -P -c http://localhost:8000
Connected (press CTRL+C to quit)
< Welcome to asgify 🚀
> hehehe
< {"echo": "hehehe", "timestamp": "2025-07-08T13:06:34.899579"}
> %
✨ Cool Features
🚀 Zero Overhead
- Pure ASGI implementation with minimal dependencies
- No magic, no hidden costs - what you write is what you get
🎯 Context Classes That Rock
The python web framework out there has the same style, but asgify is different because it uses Context to handle requests and responses!
# HTTP Context - Simple & Powerful
await ctx.start(HTTP_200_OK, {"content-type": "application/json"})
await ctx.end(json.dumps({"message": "Hello World"}).encode())
# WebSocket Context - Real-time Ready
await ctx.accept()
message = await ctx.receive_text()
await ctx.send_text(f"Echo: {message}")
🎨 Customizable Everything
- Swap context classes for your needs
- Custom lifespan handlers for app lifecycle
- Full control over request/response flow
📦 Minimal Dependencies
- Only
asgiref,fast-query-parsersandmultidict - No bloat, no surprises
🔧 Developer Experience
- Clean, intuitive API
- Comprehensive status codes (HTTP + WebSocket)
- Built-in query parameter parsing
- Application state management
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 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 asgify-0.2.0.tar.gz.
File metadata
- Download URL: asgify-0.2.0.tar.gz
- Upload date:
- Size: 12.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b731a0a21a9a95be4a7535501f90c1962d7ea7857d2aa1d20ad74456b2359c97
|
|
| MD5 |
c7d425856aa74da181afac72b79795aa
|
|
| BLAKE2b-256 |
2241d89ddf620f2fe5e19f0cdaaa9a7553f4f2904d9d06984b7afcf34cb133eb
|
Provenance
The following attestation bundles were made for asgify-0.2.0.tar.gz:
Publisher:
python-publish.yml on aprilahijriyan/asgify
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
asgify-0.2.0.tar.gz -
Subject digest:
b731a0a21a9a95be4a7535501f90c1962d7ea7857d2aa1d20ad74456b2359c97 - Sigstore transparency entry: 268642420
- Sigstore integration time:
-
Permalink:
aprilahijriyan/asgify@10ee4a325077dd364a106f0f065b7ba8a35e2d0f -
Branch / Tag:
refs/tags/0.2.0 - Owner: https://github.com/aprilahijriyan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@10ee4a325077dd364a106f0f065b7ba8a35e2d0f -
Trigger Event:
release
-
Statement type:
File details
Details for the file asgify-0.2.0-py3-none-any.whl.
File metadata
- Download URL: asgify-0.2.0-py3-none-any.whl
- Upload date:
- Size: 11.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bff15c2685f34f7ea254bc9c1e5ef9b355a6b8f961d6d600922b39e182de39ae
|
|
| MD5 |
ae6b631c93a6dc1585a3499a38132e48
|
|
| BLAKE2b-256 |
cb67b44d1a3a05485de022d628f9f3290920c332ef921bed87c4aae491b5dcd5
|
Provenance
The following attestation bundles were made for asgify-0.2.0-py3-none-any.whl:
Publisher:
python-publish.yml on aprilahijriyan/asgify
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
asgify-0.2.0-py3-none-any.whl -
Subject digest:
bff15c2685f34f7ea254bc9c1e5ef9b355a6b8f961d6d600922b39e182de39ae - Sigstore transparency entry: 268642423
- Sigstore integration time:
-
Permalink:
aprilahijriyan/asgify@10ee4a325077dd364a106f0f065b7ba8a35e2d0f -
Branch / Tag:
refs/tags/0.2.0 - Owner: https://github.com/aprilahijriyan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@10ee4a325077dd364a106f0f065b7ba8a35e2d0f -
Trigger Event:
release
-
Statement type: