def request_response(func: typing.Callable) -> ASGIApp:
    """
    Takes a function or coroutine `func(request) -> response`,
    and returns an ASGI application.
    """
    is_coroutine = asyncio.iscoroutinefunction(func)

    async def app(scope: Scope, receive: Receive, send: Send) -> None:
        request = Request(scope, receive=receive)
        if is_coroutine:
            response = await func(request)
        else:
            response = await run_in_threadpool(func, request)
        await response(scope, receive, send)

    return app
def request_response(func: typing.Callable) -> ASGIApp:
    """
    Takes a function or coroutine `func(request) -> response`,
    and returns an ASGI application.
    """
    is_coroutine = asyncio.iscoroutinefunction(func)

    async def app(scope: Scope, receive: Receive, send: Send) -> None:
        request = Request(scope, receive=receive)
        if is_coroutine:
            response = await func(request)
        else:
            response = await run_in_threadpool(func, request)
        await response(scope, receive, send)

    return app
def request_response ( func : typing . Callable ) -> ASGIApp : is_coroutine = asyncio . iscoroutinefunction ( func ) async def app ( scope : Scope , receive : Receive , send : Send ) -> None : request = Request ( scope , receive = receive ) if is_coroutine : response = await func ( request ) else : response = await run_in_threadpool ( func , request ) await response ( scope , receive , send ) return app
Takes a function or coroutine `func(request) -> response`,
    and returns an ASGI application.
Takes a function or coroutine func ( request ) - > response and returns an ASGI application .