Skip to main content

Ultra-fast Rust-powered Python async web framework

Project description

Cello

Cello

Ultra-fast Rust-powered Python web framework

CI PyPI Python License

Quick StartFeaturesExamplesDocumentation


Why Cello?

Cello is the fastest Python web framework — combining Python's developer experience with Rust's raw performance. All HTTP handling, routing, JSON serialization, and middleware execute in native Rust. Python handles only your business logic.

┌─────────────────────────────────────────────────────────────────┐
│  Request → Rust HTTP Engine → Python Handler → Rust Response   │
│                  │                    │                         │
│                  ├─ SIMD JSON         ├─ Return dict            │
│                  ├─ Radix routing     └─ Return Response        │
│                  └─ Middleware (Rust)                           │
└─────────────────────────────────────────────────────────────────┘

📦 Installation

pip install cello-framework

From source:

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

Requirements: Python 3.12+


🚀 Quick Start

from cello import App, Response

app = App()

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

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

@app.post("/users")
def create_user(request):
    data = request.json()
    return Response.json({"id": 1, **data}, status=201)

if __name__ == "__main__":
    app.run()
python app.py
# 🚀 Cello running at http://127.0.0.1:8000

✨ Features

Core Features

Feature Description
🚀 Blazing Fast Tokio + Hyper async HTTP engine in pure Rust
📦 SIMD JSON SIMD-accelerated JSON parsing with simd-json
�️ Radix Routing Ultra-fast route matching with matchit
🔄 Async/Sync Support for both async def and regular def handlers
�🛡️ Middleware Built-in CORS, logging, compression, rate limiting
Blueprints Flask-like route grouping and modular apps
🌐 WebSocket Real-time bidirectional communication
📡 SSE Server-Sent Events for streaming
📁 Multipart File uploads and form data handling

Enterprise Features

Feature Description
🔐 Authentication JWT, Basic Auth, API Key with constant-time validation
🛡️ CSRF Protection Double-submit cookie and signed token patterns
⏱️ Rate Limiting Token bucket and sliding window algorithms
🍪 Sessions Secure cookie-based session management
Security Headers CSP, HSTS, X-Frame-Options, Referrer-Policy
🏭 Cluster Mode Multi-worker process deployment
TLS/SSL Native HTTPS with rustls
HTTP/2 & HTTP/3 Modern protocol support including QUIC
Timeouts Request/response timeout protection

� Examples

Blueprints (Route Grouping)

from cello import App, Blueprint

# Create versioned API blueprint
api_v1 = Blueprint("/api/v1")

@api_v1.get("/users")
def list_users(request):
    return {"users": [{"id": 1, "name": "Alice"}, {"id": 2, "name": "Bob"}]}

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

@api_v1.post("/users")
def create_user(request):
    return Response.json(request.json(), status=201)

# Mount blueprint
app = App()
app.register_blueprint(api_v1)
app.run()

Async Handlers

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

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

@app.post("/data")
async def process_data(request):
    data = request.json()
    result = await external_api.process(data)
    return {"result": result}

Request Object

@app.post("/example")
def handler(request):
    # Request properties
    request.method              # "GET", "POST", etc.
    request.path                # "/users/123"
    request.params["id"]        # Path parameters
    request.query["search"]     # Query parameters (?search=value)
    request.get_header("Authorization")
    
    # Body parsing
    request.body()              # Raw bytes
    request.text()              # String body
    request.json()              # Parsed JSON dict
    request.form()              # Form data dict
    
    return {"received": True}

Response Types

from cello import Response

# JSON (default - just return a dict)
return {"data": "value"}

# Explicit JSON with status
return Response.json({"created": True}, status=201)

# Text response
return Response.text("Hello, World!")

# HTML response
return Response.html("<h1>Welcome</h1>")

# File download
return Response.file("/path/to/document.pdf")

# Redirect
return Response.redirect("/new-location")

# No content (204)
return Response.no_content()

# Binary data
return Response.binary(image_bytes, content_type="image/png")

# Custom headers
response = Response.json({"ok": True})
response.set_header("X-Custom", "value")
return response

Middleware

app = App()

# CORS - Cross-Origin Resource Sharing
app.enable_cors()
app.enable_cors(origins=["https://example.com", "https://app.example.com"])

# Request logging
app.enable_logging()

# Gzip compression
app.enable_compression()
app.enable_compression(min_size=1024)  # Only compress if > 1KB

# Security headers (CSP, HSTS, X-Frame-Options, etc.)
app.enable_security_headers()

# Rate limiting
app.enable_rate_limit(requests=100, window=60)  # 100 req/min

WebSocket

@app.websocket("/ws/chat")
def chat_handler(ws):
    ws.send_text("Welcome to the chat!")
    
    while True:
        message = ws.recv()
        if message is None:
            break
        
        # Echo back
        ws.send_text(f"You said: {message.text}")
        
        # Or send JSON
        ws.send_json({"type": "message", "content": message.text})

Server-Sent Events (SSE)

from cello import SseEvent, SseStream

@app.get("/events")
def event_stream(request):
    stream = SseStream()
    
    # Simple data
    stream.add_data("Connection established")
    
    # Named events with JSON
    stream.add_event("update", '{"count": 42}')
    stream.add_event("notification", '{"message": "New data available"}')
    
    return stream

JWT Authentication

from cello import App
from cello.middleware import JwtConfig, JwtAuth

# Configure JWT
jwt_config = JwtConfig(secret=b"your-secret-key-min-32-bytes-long")
jwt_auth = JwtAuth(jwt_config).skip_path("/public")

app = App()
app.use(jwt_auth)

@app.get("/protected")
def protected(request):
    claims = request.context.get("jwt_claims")
    return {"user": claims["sub"]}

🛠️ CLI & Configuration

# Development mode (hot reload + debug logs)
python app.py --env development --reload

# Production mode
python app.py --env production --workers 8 --port 8080 --no-logs
Argument Default Description
--host 127.0.0.1 Host to bind to
--port 8000 Port to bind to
--env development Environment mode
--reload False Hot reload on file changes
--workers CPU count Number of worker threads
--debug Auto Enable debug logging
--no-logs False Disable request logging
# Programmatic configuration
app.run(
    host="0.0.0.0",
    port=8080,
    env="production",
    workers=4
)

🏗️ Tech Stack

Component Technology
Runtime Tokio (async Rust)
HTTP Server Hyper 1.x
JSON simd-json + serde
Routing matchit (radix tree)
Python Bindings PyO3
TLS/SSL rustls
HTTP/2 h2
HTTP/3 quinn (QUIC)
Compression flate2 (gzip)
JWT jsonwebtoken
Concurrent Maps dashmap
Security subtle (constant-time ops)

🔒 Security

Cello is built with security as a priority:

  • Constant-time comparison for passwords, API keys, and tokens
  • CSRF protection with double-submit cookies and signed tokens
  • Security headers (CSP, HSTS, X-Frame-Options, Referrer-Policy)
  • Rate limiting to prevent abuse
  • Session security (Secure, HttpOnly, SameSite cookies)
  • Path traversal protection in static file serving
  • JWT blacklisting for token revocation

📊 Benchmarks

Cello is designed to be the fastest Python web framework:

  • Zero-copy request parsing
  • SIMD-accelerated JSON
  • Arena allocation for memory efficiency
  • Lock-free concurrent data structures
  • Native Rust HTTP handling

Benchmark results coming soon


🛠️ Development

# Setup
git clone https://github.com/jagadeesh32/cello.git
cd cello
python -m venv .venv
source .venv/bin/activate
pip install maturin pytest requests

# Build
maturin develop

# Test
pytest tests/ -v

# Lint
cargo clippy
cargo fmt

📚 Documentation

Full documentation: docs/README.md


🤝 Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.


📄 License

MIT License - see LICENSE


👤 Author

Jagadeesh Katla


Made with ❤️ and 🦀

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.4.0.tar.gz (184.0 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.4.0-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl (940.6 kB view details)

Uploaded PyPymanylinux: glibc 2.28+ ARM64

cello_framework-0.4.0-pp39-pypy39_pp73-manylinux_2_28_aarch64.whl (940.7 kB view details)

Uploaded PyPymanylinux: glibc 2.28+ ARM64

cello_framework-0.4.0-pp38-pypy38_pp73-manylinux_2_28_aarch64.whl (941.2 kB view details)

Uploaded PyPymanylinux: glibc 2.28+ ARM64

cello_framework-0.4.0-pp37-pypy37_pp73-manylinux_2_28_aarch64.whl (942.0 kB view details)

Uploaded PyPymanylinux: glibc 2.28+ ARM64

cello_framework-0.4.0-cp312-abi3-win_amd64.whl (824.6 kB view details)

Uploaded CPython 3.12+Windows x86-64

cello_framework-0.4.0-cp312-abi3-manylinux_2_28_aarch64.whl (941.0 kB view details)

Uploaded CPython 3.12+manylinux: glibc 2.28+ ARM64

cello_framework-0.4.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (941.5 kB view details)

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

cello_framework-0.4.0-cp312-abi3-macosx_11_0_arm64.whl (854.2 kB view details)

Uploaded CPython 3.12+macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: cello_framework-0.4.0.tar.gz
  • Upload date:
  • Size: 184.0 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.4.0.tar.gz
Algorithm Hash digest
SHA256 fd5813ce2e0007ddaaf7df89995ce2d9c298005aa5b24575d6e319ec38d081af
MD5 764dcde3f944eacdb2b56744d5e6abab
BLAKE2b-256 9b56098fe8354410ebd2001c3442a414b7952209426f2e548a95474eaa903607

See more details on using hashes here.

Provenance

The following attestation bundles were made for cello_framework-0.4.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.4.0-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for cello_framework-0.4.0-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 8df4957f07434d994c0c9adbff9b527d4425c65146173d7b9b1eac8519ee411d
MD5 0efe2e4dcb8ef0b736983f8a7d36b3b2
BLAKE2b-256 affda392b887b883393e10c9336068e9b97e8eeafc031abb04ca98d7c3c26d6f

See more details on using hashes here.

Provenance

The following attestation bundles were made for cello_framework-0.4.0-pp310-pypy310_pp73-manylinux_2_28_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.4.0-pp39-pypy39_pp73-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for cello_framework-0.4.0-pp39-pypy39_pp73-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 27b7533315a75c16d3d660feafbdc5cf7ec4fdfed3f49827cf4a95cb9ef43394
MD5 207ea36aa3c470521fcf3d15f576ceac
BLAKE2b-256 4f5d9ef5c14d105c4cafdc352f1598317ffb7868ce4b07f774e62f23c22297a6

See more details on using hashes here.

Provenance

The following attestation bundles were made for cello_framework-0.4.0-pp39-pypy39_pp73-manylinux_2_28_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.4.0-pp38-pypy38_pp73-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for cello_framework-0.4.0-pp38-pypy38_pp73-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 272a5c7b53da75f29aea0396d09909cf88efab0f307370e08aac927d2e97cb0e
MD5 7b8136fb295006fd5a29e031549cbba1
BLAKE2b-256 a6a6f0aa5b0f97d4e4bda8ec112f613420a2b115d6197bed47c65a17d075a901

See more details on using hashes here.

Provenance

The following attestation bundles were made for cello_framework-0.4.0-pp38-pypy38_pp73-manylinux_2_28_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.4.0-pp37-pypy37_pp73-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for cello_framework-0.4.0-pp37-pypy37_pp73-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 7e0e268a7e733b57fee0d1858d525a96f4b939c591b55b9e934dbe650efc3b41
MD5 e93c6a33d5eed9f43cdf6a7bb721460e
BLAKE2b-256 0a2175ae069df8392c871a84e9e478f2a967d501fb4d17a1f4b70b055392e90c

See more details on using hashes here.

Provenance

The following attestation bundles were made for cello_framework-0.4.0-pp37-pypy37_pp73-manylinux_2_28_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.4.0-cp312-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for cello_framework-0.4.0-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 fb8caeece8157d443957f7c5a826dcaf05bfd3422a515cb865bc620361f53e6d
MD5 da3ca97262f12f25a341620967b8a349
BLAKE2b-256 198c23508361e098095ca99647c9b764acd675f56688ea1a1386a9d4481490f2

See more details on using hashes here.

Provenance

The following attestation bundles were made for cello_framework-0.4.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.4.0-cp312-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for cello_framework-0.4.0-cp312-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 d472bc492b22a78ad2517b25edff9051b1c6acd1e6e37cab50469a4541e02189
MD5 8176de09a5cf06599b62f5b890318dc6
BLAKE2b-256 0893044fc2a0942594e016027f0700b1fa9f0d36d940540dd61ade2d97722ff3

See more details on using hashes here.

Provenance

The following attestation bundles were made for cello_framework-0.4.0-cp312-abi3-manylinux_2_28_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.4.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cello_framework-0.4.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8c4baa73ec3ae148b3b32d69efe2ce98f494bbb816354b70ec30a0f60cda669b
MD5 875c2cbe16cdcefe518e4d134701c4ea
BLAKE2b-256 930b1b51d3eb7c761206db3d98c670b6846ba01c9a7a2b8a609943303ccadd93

See more details on using hashes here.

Provenance

The following attestation bundles were made for cello_framework-0.4.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.4.0-cp312-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cello_framework-0.4.0-cp312-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ddcddf80f9a577b26727bca0c5fc5598c4b50912606443ddc9b80f8ac5e18b6b
MD5 7c9e2cbcddb8e45f5a75837d05b670d4
BLAKE2b-256 f1051fde8829936e643670b5f2981958939f6b1021a27a2d7d5e97af1265466d

See more details on using hashes here.

Provenance

The following attestation bundles were made for cello_framework-0.4.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