python-dependency-injector/examples/miniapps/sanic/giphynavigator/application.py
2021-09-30 18:56:29 -04:00

20 lines
482 B
Python

"""Application module."""
from sanic import Sanic
from .containers import Container
from . import handlers
def create_app() -> Sanic:
"""Create and return Sanic application."""
container = Container()
container.config.from_yaml("config.yml")
container.config.giphy.api_key.from_env("GIPHY_API_KEY")
container.wire(modules=[handlers])
app = Sanic("giphy-navigator")
app.ctx.container = container
app.add_route(handlers.index, "/")
return app