mirror of
https://github.com/ijaric/voice_assistant.git
synced 2025-05-24 14:33:26 +00:00
feat: example of httpx async client
This commit is contained in:
parent
47f898ae18
commit
8f2065e31f
12
src/fastapi_app/lib/clients/httpx.py
Normal file
12
src/fastapi_app/lib/clients/httpx.py
Normal file
|
@ -0,0 +1,12 @@
|
|||
# Purpose: Provide an example of an async http client for the application
|
||||
import contextlib
|
||||
import typing
|
||||
|
||||
import httpx
|
||||
|
||||
|
||||
@contextlib.asynccontextmanager
|
||||
async def get_http_client() -> typing.AsyncGenerator[httpx.AsyncClient, None]:
|
||||
client = httpx.AsyncClient() # Insert your own settings here
|
||||
async with client as ac:
|
||||
yield ac
|
Loading…
Reference in New Issue
Block a user