python-dependency-injector/examples/miniapps/fastapi/giphynavigator/endpoints.py

20 lines
478 B
Python
Raw Normal View History

2020-11-13 01:48:07 +03:00
"""Endpoints module."""
from dependency_injector.wiring import inject, Provide
2020-11-13 01:48:07 +03:00
from .containers import Container
@inject
2020-11-13 01:48:07 +03:00
async def index(
query: str = Provide[Container.config.default.query],
limit: int = Provide[Container.config.default.limit.as_int()],
2020-11-13 01:56:47 +03:00
search_service=Provide[Container.search_service],
2020-11-13 01:48:07 +03:00
):
gifs = await search_service.search(query, limit)
return {
'query': query,
'limit': limit,
'gifs': gifs,
}