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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiohttp_asgi-0.6.0.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

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

aiohttp_asgi-0.6.0-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file aiohttp_asgi-0.6.0.tar.gz.

File metadata

  • Download URL: aiohttp_asgi-0.6.0.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.13.2 Darwin/24.4.0

File hashes

Hashes for aiohttp_asgi-0.6.0.tar.gz
Algorithm Hash digest
SHA256 798f685013ba77e3e0a954a28b2f404900b674f1725217c165abcdfaa09a740c
MD5 13034f8abc5964353bed734bf8a79ae4
BLAKE2b-256 0498c9ed329328b39f0beb74d207e8aaeb047e44c63028ab82e9ad82666543a3

See more details on using hashes here.

File details

Details for the file aiohttp_asgi-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: aiohttp_asgi-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 15.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.13.2 Darwin/24.4.0

File hashes

Hashes for aiohttp_asgi-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0af9cd08daff1155ba0e8f5e4580efd7b38707903cf6802c2e5df22df04da159
MD5 de2e419e0e74278051392f09dbcbad7f
BLAKE2b-256 2459b9acae33dc024eb7545ed7b795e4f3883bbce23c93f65d27d992eaba59ee

See more details on using hashes here.

Release history Release notifications | RSS feed

0.6.1

2 files

This release

0.6.0 This release

2 files

0.5.2

2 files

0.5.0

2 files

0.4.3

2 files

0.4.2

2 files

0.4.1

2 files

0.4.0

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.0

2 files

0.1.0

1 file

0.0.1

1 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