python-dependency-injector/examples/miniapps/ghnav-flask/githubnavigator/containers.py
Roman Mogylatov 1674cecc8d
Flask tutorial (#265)
* Add a piece of the tutorial

* Add "Make it pretty" tutorial step

* Add section about github client setup

* Make minor fixes

* Add search service section + table of contents

* Make various fixes

* Make more fixes

* Update make the search section

* Update ghnav-flask example & README

* Update base.html markup

* Finish section: Make the search work

* Update ghnav-flask screenshot

* Update tutorials

* Add flaks tutorial link to the DI in Python page
2020-07-20 16:58:18 -04:00

38 lines
951 B
Python

"""Application containers module."""
from dependency_injector import containers, providers
from dependency_injector.ext import flask
from flask import Flask
from flask_bootstrap import Bootstrap
from github import Github
from . import views, services
class ApplicationContainer(containers.DeclarativeContainer):
"""Application container."""
app = flask.Application(Flask, __name__)
bootstrap = flask.Extension(Bootstrap)
config = providers.Configuration()
github_client = providers.Factory(
Github,
login_or_token=config.github.auth_token,
timeout=config.github.request_timeout,
)
search_service = providers.Factory(
services.SearchService,
github_client=github_client,
)
index_view = flask.View(
views.index,
search_service=search_service,
default_query=config.search.default_query,
default_limit=config.search.default_limit,
)