Skip to main content

Ultra-fast Rust-powered Python async web framework

Project description

Cello

The World's Fastest 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

Advanced 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
🆔 Request ID Automatic request tracing with UUID
📏 Body Limits Request size validation and protection
📂 Static Files Efficient static file serving with caching
🏷️ ETag/Caching HTTP caching with ETag support
⚠️ Exception Handling Global error handlers with RFC 7807 support
🔄 Lifecycle Hooks Startup/shutdown events for app initialization
📦 DTOs Data Transfer Objects with field filtering

🆕 New in v0.5.1 - Best of FastAPI, Litestar, Robyn & Django!

Feature Inspired By Description
💉 Dependency Injection FastAPI Type-safe DI with Singleton/Request/Transient scopes
🛡️ Guards (RBAC) Litestar Role & permission-based access control with composable guards
📊 Prometheus Metrics Litestar Production-ready metrics with automatic /metrics endpoint
📄 OpenAPI/Swagger FastAPI Auto-generated API documentation at /docs
🎯 Background Tasks FastAPI Execute tasks after response is sent
📝 Template Rendering Django Jinja2-compatible template support

All implemented in pure Rust for maximum performance! See docs/new-middleware-features.md for details.


� Examples

🎯 Advanced Features Demo (v0.5.1)

See examples/comprehensive_demo.py for a complete demonstration of all new features:

  • Dependency Injection
  • Guards/RBAC
  • Prometheus Metrics
  • Exception Handling
  • Advanced Caching
  • DTO System
python examples/comprehensive_demo.py

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 ❤️ using 🐍 Python and 🦀 Rust

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.5.1.tar.gz (1.2 MB 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.5.1-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl (1.4 MB view details)

Uploaded PyPymanylinux: glibc 2.28+ ARM64

cello_framework-0.5.1-pp39-pypy39_pp73-manylinux_2_28_aarch64.whl (1.4 MB view details)

Uploaded PyPymanylinux: glibc 2.28+ ARM64

cello_framework-0.5.1-pp38-pypy38_pp73-manylinux_2_28_aarch64.whl (1.4 MB view details)

Uploaded PyPymanylinux: glibc 2.28+ ARM64

cello_framework-0.5.1-pp37-pypy37_pp73-manylinux_2_28_aarch64.whl (1.4 MB view details)

Uploaded PyPymanylinux: glibc 2.28+ ARM64

cello_framework-0.5.1-cp312-abi3-win_amd64.whl (1.2 MB view details)

Uploaded CPython 3.12+Windows x86-64

cello_framework-0.5.1-cp312-abi3-manylinux_2_28_aarch64.whl (1.4 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.28+ ARM64

cello_framework-0.5.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.4 MB view details)

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

cello_framework-0.5.1-cp312-abi3-macosx_11_0_arm64.whl (1.3 MB view details)

Uploaded CPython 3.12+macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for cello_framework-0.5.1.tar.gz
Algorithm Hash digest
SHA256 c4fb7fc4eb70dc5eb5c94aff69d2b3eacc5fe1aa4399cc1fcc05c6ee2eca9968
MD5 98f0ddd748c6ab51da9ad06aeaf85e07
BLAKE2b-256 64253b27300b01ea430225b390086782a40b4b661a5a8d6c603cd47e0772d953

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cello_framework-0.5.1-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 72acf42279a3842f9eefff820f2c5e48519e661f105d379e8ca054a4d7193caf
MD5 df28470dc56bfc568045902c5c7c80c1
BLAKE2b-256 30c04f0820f2813eb265195662080c09fd2bac424bf7bbe2403fccb011aa4560

See more details on using hashes here.

Provenance

The following attestation bundles were made for cello_framework-0.5.1-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.5.1-pp39-pypy39_pp73-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for cello_framework-0.5.1-pp39-pypy39_pp73-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 0bedbab6caceef1cd64ab7876ba536cca109d503b660675ed8674f1140830e56
MD5 9ef78df53c1b87d0fba82cb9c088cad9
BLAKE2b-256 98a85adfa2d92f040d3e03d13316c523c077662b0f358b4e6ef7c3957a53c8af

See more details on using hashes here.

Provenance

The following attestation bundles were made for cello_framework-0.5.1-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.5.1-pp38-pypy38_pp73-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for cello_framework-0.5.1-pp38-pypy38_pp73-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 ffbf85282b492b7f5b5df69c997396c2409f32c94d658263ee14fd66da88a3d5
MD5 fbf2d762ce142b99753ff2e31c6e5417
BLAKE2b-256 717294d68d6d578edd16a0da31b11b2994daea905892acec10b3ef69cb2cb95a

See more details on using hashes here.

Provenance

The following attestation bundles were made for cello_framework-0.5.1-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.5.1-pp37-pypy37_pp73-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for cello_framework-0.5.1-pp37-pypy37_pp73-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e0a8197bfa2f694c2a2a2fd23d5e4cad237d36aa51b88cdb889a5a5cdc8bd248
MD5 5d04dcd5d012f6a0959010e355754579
BLAKE2b-256 3e59712010a0f7eeb7e157100636bfcaf97d3fce1a188e3d64d24d76517d16c7

See more details on using hashes here.

Provenance

The following attestation bundles were made for cello_framework-0.5.1-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.5.1-cp312-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for cello_framework-0.5.1-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 e5df3fcf4f97efd077a9064c47e9a44331a74653e122018ea108a5136d0560ee
MD5 24bea8af69dc9c87e8649e7c78c85e60
BLAKE2b-256 bc6d3880ff03994cf4ac825fac9beac2178473ffdfbb691999e9149b9d585e78

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cello_framework-0.5.1-cp312-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 bab3a5c2f5dbbf6d7d448e744e068422c919ff502fec5f27346e9756adcec456
MD5 38673f640e89e894eba8ef1c0f24b756
BLAKE2b-256 ba35cc462281627bac0476c2cab07bf14c83e43a87cea01e60a146181546e508

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cello_framework-0.5.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2c5cf4a817905bcc72853346410bb5b4703f09dcce5db42f11067d4bfc0fabd9
MD5 466f236c6daf17339881a599aa84decd
BLAKE2b-256 a51fbaecf9dcf775645c3731135f91fee6df2bdf454e75a74bfed9369754d5d0

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cello_framework-0.5.1-cp312-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5710370b750713b6c94aa6da03cdb8edfd32479067c7e786dddb9d8c075f65ce
MD5 3e784dd8ef19f53dc74e97be6f7b59b2
BLAKE2b-256 2b17f26046864e64874044b55f398ae337a1eb1311e546906d9dc4319888939e

See more details on using hashes here.

Provenance

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