Skip to main content

aiohttp-asgi

PyPI - License Wheel PyPI PyPI Coverage Status tests

This module provides a way to use any ASGI compatible frameworks and aiohttp together.

Example

from aiohttp import web
from fastapi import FastAPI
from starlette.requests import Request as ASGIRequest

from aiohttp_asgi import ASGIResource


asgi_app = FastAPI()


@asgi_app.get("/asgi")
async def root(request: ASGIRequest):
    return {
        "message": "Hello World",
        "root_path": request.scope.get("root_path")
    }


aiohttp_app = web.Application()

# Create ASGIResource which handle
# any request startswith "/asgi"
asgi_resource = ASGIResource(asgi_app, root_path="/asgi")

# Register resource
aiohttp_app.router.register_resource(asgi_resource)

# Mount startup and shutdown events from aiohttp to ASGI app
asgi_resource.lifespan_mount(aiohttp_app)

# Start the application
web.run_app(aiohttp_app)

Installation

pip install aiohttp-asgi

ASGI HTTP server

Command line tool for starting aiohttp web server with ASGI app.

Example

Create the test_app.py

from starlette.applications import Starlette
from starlette.responses import JSONResponse
from starlette.routing import Route


async def homepage(request):
    return JSONResponse({'hello': 'world'})

routes = [
    Route("/", endpoint=homepage)
]

application = Starlette(debug=True, routes=routes)

and run the test_app.py with aiohttp-asgi

aiohttp-asgi \
    --address "[::1]" \
    --port 8080 \
    test_app:application

alternatively using python -m

python -m aiohttp_asgi \
    --address "[::1]" \
    --port 8080 \
    test_app:application

Release files for aiohttp_asgi 0.6.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aiohttp_asgi 0.6.1
File Size Uploaded
aiohttp_asgi-0.6.1.tar.gz 10.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aiohttp_asgi 0.6.1
File Interpreter ABI Platform
aiohttp_asgi-0.6.1-py3-none-any.whl Python 3 none any Details

Total release size: 26.9 kB

Release files / aiohttp_asgi-0.6.1.tar.gz

Download URL aiohttp_asgi-0.6.1.tar.gz
Size 10.9 kB
Tags Source
SHA-256 checksum
How to use checksums
bc86dec9c0e4aac75d82997ea8201c7ea7443841f168f997da7716d0d4def9d5
BLAKE2b-256 checksum
How to use checksums
a7695d1d9308932508996fa5c87dc72b3c4c017ffee1e2aa1c44102bcb480878
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.13.2 Darwin/24.4.0

Release files / aiohttp_asgi-0.6.1-py3-none-any.whl

Download URL aiohttp_asgi-0.6.1-py3-none-any.whl
Size 16.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6419fb2be43b3c9163973804d853fc8f4a04fa93a1f31e7065f358c68891144d
BLAKE2b-256 checksum
How to use checksums
916e35a4d9243339a18517b0ffd3539cc7ca4f29ac816da32a02a4540e1c70aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.13.2 Darwin/24.4.0

Release history Release notifications | RSS feed

This release

0.6.1 This release

2 release files

0.6.0

2 release files

0.5.2

2 release files

0.5.0

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page