Skip to main content

Ultra-fast Rust-powered Python async web framework

Project description

Cello 🐍

CI PyPI Python License

Ultra-fast Rust-powered Python async web framework

Cello is a high-performance web framework that combines Python's developer experience with Rust's raw speed. All HTTP handling, routing, and JSON serialization happen in Rust—Python handles only your business logic.

✨ Features

Feature Description
🚀 Blazing Fast Tokio + Hyper HTTP engine in pure Rust
📦 SIMD JSON SIMD-accelerated JSON with simd-json
🛡️ Middleware Built-in CORS, logging, gzip compression
🗺️ Blueprints Flask-like route grouping
🌐 WebSocket Real-time bidirectional communication
📡 SSE Server-Sent Events streaming
📁 File Uploads Multipart form data handling
🐍 Pythonic Decorator-based routing like Flask

📦 Installation

pip install cello-framework

From source:

pip install maturin
git clone https://github.com/jagadeeshkatla/cello.git
cd cello
maturin develop

🚀 Quick Start

from cello import App, Response

app = App()

# Enable middleware
app.enable_cors()
app.enable_logging()
app.enable_compression()

@app.get("/")
def home(request):
    return {"message": "Hello, Cello!"}

@app.get("/users/{id}")
def get_user(request):
    user_id = request.params["id"]
    return {"id": user_id, "name": "John"}

@app.post("/users")
def create_user(request):
    data = request.json()
    return {"id": 1, "name": data["name"]}

if __name__ == "__main__":
    app.run()

🛠️ CLI & Configuration

Cello comes with built-in CLI argument parsing. You can configure the server using command-line arguments without changing your code.

Development Mode (Hot Reload + Debug Logs)

python main.py --env development --reload

Production Mode (Fast + No Debug Logs)

python main.py --env production --no-logs --workers 8 --port 8080

Available Options

Argument Default Description
--host 127.0.0.1 Host to bind to
--port 8000 Port to bind to
--env development Environment (development or production)
--reload False Enable hot reloading (restarts on file change)
--workers CPU Count Number of worker threads
--debug Auto Enable debug logs (default True in dev)
--no-logs False Disable all request logging
# You can also set defaults in code
app.run(
    host="0.0.0.0", 
    port=5000, 
    env="production", 
    workers=4
)

📖 Documentation

Blueprints

Group routes with shared prefixes:

from cello import App, Blueprint

api = Blueprint("/api/v1")

@api.get("/users")
def list_users(request):
    return {"users": []}

@api.get("/users/{id}")
def get_user(request):
    return {"id": request.params["id"]}

app = App()
app.register_blueprint(api)
app.run()

Request Object

def handler(request):
    request.method              # "GET", "POST", etc.
    request.path                # "/users/123"
    request.params["id"]        # Path parameters
    request.query["search"]     # Query parameters
    request.get_header("auth")  # Headers
    request.body()              # Raw bytes
    request.text()              # String body
    request.json()              # Parsed JSON
    request.form()              # Form data dict

Response Types

from cello import Response

# JSON (default)
return {"data": "value"}

# Custom responses
return Response.json({"ok": True}, status=201)
return Response.text("Hello!")
return Response.html("<h1>Hello</h1>")
return Response.file("/path/to/file.pdf")
return Response.redirect("/new-url")
return Response.no_content()

Async Handlers

Cello supports both sync and async handlers - use whichever fits your needs:

# Sync handler - for simple, CPU-bound operations
@app.get("/sync")
def sync_handler(request):
    return {"message": "Hello from sync!"}

# Async handler - for I/O operations (database, HTTP, files)
@app.get("/async")
async def async_handler(request):
    data = await database.fetch_users()
    return {"users": data}

# Mix freely in the same app
@app.post("/users")
async def create_user(request):
    user = request.json()
    await database.insert_user(user)
    return {"id": user["id"], "created": True}

When to use async def:

  • Database queries (asyncpg, motor, databases)
  • HTTP requests (httpx, aiohttp)
  • File I/O (aiofiles)
  • Any operation that benefits from non-blocking I/O

Middleware

app = App()

# CORS - allow cross-origin requests
app.enable_cors()
app.enable_cors(origins=["https://example.com"])

# Logging - log all requests
app.enable_logging()

# Compression - gzip responses
app.enable_compression()
app.enable_compression(min_size=1024)

WebSocket

@app.websocket("/ws")
def websocket_handler(ws):
    ws.send_text("Welcome!")
    while True:
        msg = ws.recv()
        if msg is None:
            break
        ws.send_text(f"Echo: {msg.text}")

Server-Sent Events

from cello import SseEvent, SseStream

@app.get("/events")
def events(request):
    stream = SseStream()
    stream.add_data("Hello")
    stream.add_event("update", '{"count": 1}')
    return stream

🏗️ Architecture

Request → Rust HTTP Engine → Python Handler → Rust Response
              │                    │
              ├─ SIMD JSON         ├─ Return dict
              ├─ Radix routing     └─ Return Response
              └─ Middleware

🛠️ Development

# Setup
python -m venv .venv
source .venv/bin/activate
pip install maturin pytest ruff

# Build & Test
maturin develop
pytest tests/ -v

# Lint
ruff check python/ tests/
cargo clippy

📊 Tech Stack

Component Technology
HTTP Server Tokio + Hyper
JSON simd-json + serde
Routing matchit (radix tree)
Python Bindings PyO3
Compression flate2 (gzip)

📄 License

MIT License - see LICENSE

👤 Author

Jagadeesh Katla

cello

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

cello_framework-0.3.0.tar.gz (55.8 kB view details)

Uploaded Source

Built Distributions

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

cello_framework-0.3.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (824.5 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ ARM64

cello_framework-0.3.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (824.5 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ ARM64

cello_framework-0.3.0-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (824.9 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ ARM64

cello_framework-0.3.0-pp37-pypy37_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (825.9 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ ARM64

cello_framework-0.3.0-cp312-abi3-win_amd64.whl (713.7 kB view details)

Uploaded CPython 3.12+Windows x86-64

cello_framework-0.3.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (821.2 kB view details)

Uploaded CPython 3.12+manylinux: glibc 2.17+ x86-64

cello_framework-0.3.0-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (824.1 kB view details)

Uploaded CPython 3.12+manylinux: glibc 2.17+ ARM64

cello_framework-0.3.0-cp312-abi3-macosx_11_0_arm64.whl (748.7 kB view details)

Uploaded CPython 3.12+macOS 11.0+ ARM64

File details

Details for the file cello_framework-0.3.0.tar.gz.

File metadata

  • Download URL: cello_framework-0.3.0.tar.gz
  • Upload date:
  • Size: 55.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cello_framework-0.3.0.tar.gz
Algorithm Hash digest
SHA256 2d9dc5c658c7ad7d653a2aedd6ff09e5ca8a1a16fc8a8999a882ab5eb1b5fcaa
MD5 e00103b12a4d94dfa60d422caa5b30ed
BLAKE2b-256 4307b2a3cf133a1fea6c6709d05401f7d8ac7189fbcd352afc9a2c34b65a23f6

See more details on using hashes here.

Provenance

The following attestation bundles were made for cello_framework-0.3.0.tar.gz:

Publisher: publish.yml on jagadeesh32/cello

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cello_framework-0.3.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for cello_framework-0.3.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 6817a0e6150b3656880439689e777236c997dbb2e7c5bc40b48750d636f89711
MD5 b5770af2fe9203fb5409b5821c1db878
BLAKE2b-256 51fc584050f6c0f526a39bfe0767e3b532f2bb231432b059ea2b0aaddd79413d

See more details on using hashes here.

Provenance

The following attestation bundles were made for cello_framework-0.3.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: publish.yml on jagadeesh32/cello

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cello_framework-0.3.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for cello_framework-0.3.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 a9892c875e3f26a5aad557c1f773947b9ab770757992018c40b0eea7b63473df
MD5 da86febbbf893544284ea8b4240c1b10
BLAKE2b-256 75a2669fc0de96810db3cecfa2911b032ea481421f7c21908efd9df3c8c41639

See more details on using hashes here.

Provenance

The following attestation bundles were made for cello_framework-0.3.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: publish.yml on jagadeesh32/cello

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cello_framework-0.3.0-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for cello_framework-0.3.0-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 dd982e80dba3c27caf68a70433e8067fde7122cd617e1d48cdbce97152915e6d
MD5 6ca3b6846a4a36efc96e09f22e08ea45
BLAKE2b-256 92eef81bd4ddeb48324c4269965153fbcd921e398a34db436b35e1146b84bf33

See more details on using hashes here.

Provenance

The following attestation bundles were made for cello_framework-0.3.0-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: publish.yml on jagadeesh32/cello

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cello_framework-0.3.0-pp37-pypy37_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for cello_framework-0.3.0-pp37-pypy37_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 057ba4b42856ce4fcf9be841f23fd134b0a5f53fcf2431053447e6ec8b847180
MD5 83f37eb245ee240ebfb20af59679d3d1
BLAKE2b-256 3904d43f19288c608ff7429a3563eb2a4ae40b781dd952750cd5e19f76f4065f

See more details on using hashes here.

Provenance

The following attestation bundles were made for cello_framework-0.3.0-pp37-pypy37_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: publish.yml on jagadeesh32/cello

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cello_framework-0.3.0-cp312-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for cello_framework-0.3.0-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 e8aff75cdb1e2f94edce07a8023065a453603c52c615705c8d2e1736eed8dee5
MD5 3eab190a0ee802fcc5403844aa004139
BLAKE2b-256 2fe042c14630649cb586fbbb886b9f1f906f6407066c8c3f102064cf1dbece3a

See more details on using hashes here.

Provenance

The following attestation bundles were made for cello_framework-0.3.0-cp312-abi3-win_amd64.whl:

Publisher: publish.yml on jagadeesh32/cello

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cello_framework-0.3.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cello_framework-0.3.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 dba740016c2176c82ad176ef7db51c464980ea0a8b488c1c6cb03702e361c21d
MD5 a7c9a3b665c67229ade2d2ba070018b4
BLAKE2b-256 9949a5feeb4e8c702011b48d09ebd4b51078b66006b37a5885fc6af2271d8a68

See more details on using hashes here.

Provenance

The following attestation bundles were made for cello_framework-0.3.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on jagadeesh32/cello

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cello_framework-0.3.0-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for cello_framework-0.3.0-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 810bdfe869459b50a1a4cd23a7c27e63b2dce375fc11100f7856e3dc899390e6
MD5 59dd1c49ce174641426bce8f766aa8b4
BLAKE2b-256 2be6e400cf8222e4e7550778238cb17ea549013ac52d098a63d8475ac6786661

See more details on using hashes here.

Provenance

The following attestation bundles were made for cello_framework-0.3.0-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: publish.yml on jagadeesh32/cello

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cello_framework-0.3.0-cp312-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cello_framework-0.3.0-cp312-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a60b4b13e0adc98409af4ab09ec12a943a5f5a3045135fb73571a0c8695472c7
MD5 b09b233462aca1765b65ab55e5e6fb31
BLAKE2b-256 757078b6645a159f112af7fa4c03049cabe9a8f63d84dca24952de36eff998bb

See more details on using hashes here.

Provenance

The following attestation bundles were made for cello_framework-0.3.0-cp312-abi3-macosx_11_0_arm64.whl:

Publisher: publish.yml on jagadeesh32/cello

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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