2020-11-13 01:48:07 +03:00
|
|
|
"""Endpoints module."""
|
|
|
|
|
2020-11-16 00:06:42 +03:00
|
|
|
from dependency_injector.wiring import inject, Provide
|
2020-11-13 01:48:07 +03:00
|
|
|
|
|
|
|
from .containers import Container
|
|
|
|
|
|
|
|
|
2020-11-16 00:06:42 +03:00
|
|
|
@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,
|
|
|
|
}
|