python-dependency-injector/examples/miniapps/giphynav-aiohttp/giphynavigator/views.py
Roman Mogylatov e0d81c2d28
Aiohttp integration (#270)
* Add aiohttp extension module

* Add giphynav-aiohttp app

* Add missing docstrings

* Remove print() call

* Remove not needed import from flask extension tests

* Improve coroutine provider tests

* Add aiohttp extension tests

* Update tox.ini

* Add aiohttp extras

* Try fix Python 3.4 tests

* Try fix 3.6 tests

* Stop running coroutine tests for Python 3.4

* Rename tests

* Remove type hints

* Fix pypy and change python version for coverage job to 3.8

* Fix coveralls job

* Try fix Python 3.4, 3.5 tests

* Make coverage job to run 3.5+ tests

* Add tests

* Add readme

* Update the readmes

* Add API docs

* Add API docs page

* Update changelog
2020-07-28 19:19:05 -04:00

26 lines
552 B
Python

"""Views module."""
from aiohttp import web
from .services import SearchService
async def index(
request: web.Request,
search_service: SearchService,
default_query: str,
default_limit: int,
) -> web.Response:
query = request.query.get('query', default_query)
limit = int(request.query.get('limit', default_limit))
gifs = await search_service.search(query, limit)
return web.json_response(
{
'query': query,
'limit': limit,
'gifs': gifs,
},
)