Skip to main content

A minimal, stable ASGI foundation - framework-agnostic toolkit for building high-performance web services

Project description

Genro ASGI

A minimal, stable ASGI foundation - framework-agnostic toolkit for building high-performance web services.

PyPI version Python Support License Documentation

Overview

Genro ASGI provides a minimal, production-ready ASGI server and application toolkit built on top of genro-routes for routing. It offers essential components for building web services with full type safety.

Key Features

  • Minimal Core: Essential components only, no bloat
  • Router Integration: Uses genro-routes for flexible, decorator-based routing
  • MCP Support: Built-in MCP Streamable HTTP transport via McpApplication
  • Production-Ready: Tested, typed, and stable
  • Type-Safe: Full type hints throughout
  • Essential Components:
    • ASGI server with config-driven application mounting
    • HTTP request/response utilities
    • Lifespan management
    • Middleware (authentication, CORS, errors, compression, cache, logging)
    • Static file serving via StaticRouter
    • WebSocket support with WSX extension protocol
    • Filesystem storage with mount system

Installation

# Basic installation
pip install genro-asgi

# With fast JSON support
pip install genro-asgi[json]

# Development installation
pip install genro-asgi[dev]

# Documentation build
pip install genro-asgi[docs]

Quick Start

CLI - Serve static files

# Create config.yaml
cat > config.yaml << EOF
server:
  host: "127.0.0.1"
  port: 8000

apps:
  static:
    module: "genro_asgi:StaticRouter"
    directory: "./public"
    index: "index.html"
EOF

# Run server
python -m genro_asgi serve .

Python - Custom server

from genro_asgi import AsgiServer

server = AsgiServer(server_dir=".")
server.run()  # Starts uvicorn

Architecture

Genro ASGI is designed around these principles:

  1. Instance Isolation: Server and apps are isolated instances, not global functions
  2. Composability: Mix and match components as needed
  3. Type Safety: Full type hints throughout
  4. Dual Parent-Child: Child objects hold a semantic reference to their parent

Core Components

  • AsgiServer: ASGI entry point, loads config, mounts apps
  • AsgiApplication: Base class for mountable applications
  • McpApplication: MCP Streamable HTTP transport
  • HttpRequest: HTTP request wrapper with headers, query, body
  • Response: HTTP response with auto content-type detection
  • Lifespan / ServerLifespan: Startup/shutdown event management
  • Dispatcher: Request routing and dispatch
  • StaticRouter: Filesystem-backed static file serving
  • LocalStorage: Filesystem storage with mount system

Middleware

  • AuthMiddleware: O(1) authentication (bearer, basic, JWT)
  • CORSMiddleware: Cross-Origin Resource Sharing headers
  • ErrorMiddleware: Exception handling and error responses
  • CompressionMiddleware: Gzip response compression
  • CacheMiddleware: HTTP response caching
  • LoggingMiddleware: Request/response logging

Documentation

Full documentation available at: https://genro-asgi.readthedocs.io

Development

Setup

# Clone repository
git clone https://github.com/genropy/genro-asgi.git
cd genro-asgi

# Install in development mode
pip install -e .[dev]

Testing

# Run tests
pytest

# With coverage
pytest --cov=genro_asgi --cov-report=html

Code Quality

# Lint code
ruff check .

# Type check
mypy src

License

This project is licensed under the Apache License 2.0.

Copyright © 2025-2026 Softwell S.r.l.

You may obtain a copy of the license at:

https://www.apache.org/licenses/LICENSE-2.0

This project may include third-party components distributed under separate open-source licenses. See the NOTICE file for additional attribution.

Contributing

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

Links

Credits

Developed by Softwell S.r.l.

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

genro_asgi-0.2.0.tar.gz (118.9 kB view details)

Uploaded Source

Built Distribution

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

genro_asgi-0.2.0-py3-none-any.whl (120.4 kB view details)

Uploaded Python 3

File details

Details for the file genro_asgi-0.2.0.tar.gz.

File metadata

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

File hashes

Hashes for genro_asgi-0.2.0.tar.gz
Algorithm Hash digest
SHA256 39095685cd0b4319af81d2a06fe9497a2c8858f04c8ffae66f59089e2fe415a0
MD5 997736118d1628e4d91d140c67b63b6d
BLAKE2b-256 afa472e5648e25529096491af79c6e3c39bda357ee5c48f8ba27eb74a4c67097

See more details on using hashes here.

Provenance

The following attestation bundles were made for genro_asgi-0.2.0.tar.gz:

Publisher: publish.yml on genropy/genro-asgi

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

File details

Details for the file genro_asgi-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: genro_asgi-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 120.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for genro_asgi-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dcf15be712ac4a9175198849a43c82ae52667d4c5fba2b8c317c1fc1099a641d
MD5 4c5eb8f5484d849ea9dbe2489da1f352
BLAKE2b-256 7dd7eed332d26b998986dcf38be8ed02c9a298b51a9ec9b99132834e8195f844

See more details on using hashes here.

Provenance

The following attestation bundles were made for genro_asgi-0.2.0-py3-none-any.whl:

Publisher: publish.yml on genropy/genro-asgi

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