Skip to content

playpauseandstop/aiohttp-middlewares

This branch is up to date with main.

Folders and files

NameName
Last commit message
Last commit date
Aug 14, 2024
Feb 28, 2023
Aug 14, 2024
Jul 25, 2022
Aug 14, 2024
Aug 14, 2024
Feb 11, 2024
Aug 14, 2024
Aug 14, 2024
Aug 31, 2022
Nov 23, 2023
Aug 14, 2024
May 13, 2017
Jan 8, 2023
Feb 11, 2024
Jun 21, 2022
Aug 14, 2024
Aug 31, 2022
Aug 14, 2024
Feb 23, 2023

Repository files navigation

aiohttp-middlewares

CI Workflow pre-commit black Latest Version Python versions BSD License Coverage Documentation

Collection of useful middlewares for aiohttp.web applications.

Quick Start

By default aiohttp.web does not provide many built-in middlewares for standart web-development needs such as: handling errors, shielding view handlers, or providing CORS headers.

aiohttp-middlewares tries to fix this by providing several middlewares that aims to cover most common web-development needs.

For example, to enable CORS headers for http://localhost:8081 origin and handle errors for aiohttp.web application you need to,

from aiohttp import web
from aiohttp_middlewares import (
    cors_middleware,
    error_middleware,
)


app = web.Application(
    middlewares=(
        cors_middleware(origins=("http://localhost:8081",)),
        error_middleware(),
    )
)

Check documentation for all available middlewares and available initialization options.