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.0 - 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.0)

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.0.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.0-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl (1.4 MB view details)

Uploaded PyPymanylinux: glibc 2.28+ ARM64

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

Uploaded PyPymanylinux: glibc 2.28+ ARM64

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

Uploaded PyPymanylinux: glibc 2.28+ ARM64

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

Uploaded PyPymanylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12+Windows x86-64

cello_framework-0.5.0-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.0-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.0-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.0.tar.gz.

File metadata

  • Download URL: cello_framework-0.5.0.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.0.tar.gz
Algorithm Hash digest
SHA256 dab705f6210cac8d6b6e0a102d633d566e0b401cdddda14e654b1134e7a79fdd
MD5 9220bbda8a666208753f924589a91d93
BLAKE2b-256 22ee823e7cf59edbc39835f516dba1062245858e634f4e62b9f145992861cb14

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cello_framework-0.5.0-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 fb2ebe45a208a8b8d8c9e386d44067dd96bf8204901e574e379cbd7a4331e491
MD5 19ffdbeff5adb26ca442a6233c3b5bcb
BLAKE2b-256 9ca0f44d5b8f109b2ce6fd780e40de3fbb24dce6958e9584141d713415c431c2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cello_framework-0.5.0-pp39-pypy39_pp73-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 fbb75696ac8a266718d3017dd48460aff5e1ba191a1d0fb6300779f69a6604f9
MD5 e5d91612336916ea46d9848bc7025b71
BLAKE2b-256 75ddb061cddeb278d73124978c7bea0f7c33fd43654cc6aa751e968630ec748a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cello_framework-0.5.0-pp38-pypy38_pp73-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 721da77af8c190c113b021eae4179b933841e387ea6397dbb62a47cc0ea08971
MD5 92624349e201656b022ca776a4d27f53
BLAKE2b-256 4bd61e454d5427e27fa04b14638037baf6c5d63f11facc8e976af5ea5c15aaaf

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cello_framework-0.5.0-pp37-pypy37_pp73-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 0f099047eed3a818aab5a140a741d70a45346910d7c7fda0c89b0d902d6060c4
MD5 737704b8a7ac0df375351693731338fe
BLAKE2b-256 b8bcfbe7703b1147407879fbe5874b077031a8f6d9c459d0efc931f1469bbd6b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cello_framework-0.5.0-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 854b0eec0e4b096b3478f0ee55fedb32d3d0c16c147ef6f59ad5de67744b9581
MD5 d289f17a6357b8a9a927198435700831
BLAKE2b-256 fd65f51414c22e7e2a73f8ce5b59c25da3e772015ea35a10883fc0829bc1f2f5

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cello_framework-0.5.0-cp312-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 ac3f027b0a248b99fc8617794d392e57e142f195b8864ada44df72995cf535c2
MD5 6eb65a92e68fd3fc3ae8457a295f25c0
BLAKE2b-256 e453173d3f28cd9f68e674b5771d4f126a3a6ea03e3c8e9be5a3b5a35b08bd79

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cello_framework-0.5.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e4d53998e3cd0f96d37109d95dc29b48ddc128209a3bae9d9e88cfe5af3dfc3c
MD5 6a7efe2b8fd70b24bb2bb9e30c27784f
BLAKE2b-256 987168b9d50bd4a029ba83e1ba71e14f3e41b446f0858d7c53676ba4d1cdf3b4

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cello_framework-0.5.0-cp312-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 182ad32b42a4b1c5a4dc36fb65cc32b988befb84978f7851bea1b839c24ffce5
MD5 10b517fc74c97d10ca06d1ae9b0c4ce8
BLAKE2b-256 5b4de668e7838fe9e6bf49aff2a43d0700f27d2b0e2282cf29dd9d27dee516c5

See more details on using hashes here.

Provenance

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