2020-07-29 02:19:05 +03:00
|
|
|
"""Application module."""
|
|
|
|
|
|
|
|
from aiohttp import web
|
|
|
|
|
2020-09-23 04:47:44 +03:00
|
|
|
from .containers import Container
|
2020-09-23 22:58:36 +03:00
|
|
|
from . import handlers
|
2020-07-29 02:19:05 +03:00
|
|
|
|
|
|
|
|
|
|
|
def create_app():
|
2020-07-30 20:52:42 +03:00
|
|
|
"""Create and return aiohttp application."""
|
2020-09-23 04:47:44 +03:00
|
|
|
container = Container()
|
2020-07-29 02:19:05 +03:00
|
|
|
container.config.from_yaml('config.yml')
|
|
|
|
container.config.giphy.api_key.from_env('GIPHY_API_KEY')
|
|
|
|
|
2020-09-23 22:58:36 +03:00
|
|
|
container.wire(modules=[handlers])
|
2020-09-23 04:47:44 +03:00
|
|
|
|
|
|
|
app = web.Application()
|
2020-07-29 02:19:05 +03:00
|
|
|
app.container = container
|
|
|
|
|
|
|
|
app.add_routes([
|
2020-09-23 22:58:36 +03:00
|
|
|
web.get('/', handlers.index),
|
2020-07-29 02:19:05 +03:00
|
|
|
])
|
|
|
|
|
|
|
|
return app
|