Refactor Flask tutorial: Search service

This commit is contained in:
Roman Mogylatov 2020-10-08 12:44:07 -04:00
parent f1c0f9ce3f
commit 5856c49614

View File

@ -591,7 +591,7 @@ Github API client setup is done.
Search service Search service
-------------- --------------
Now it's time to add the ``SearchService``. It will: Now it's time to add ``SearchService``. It will:
- Perform the search. - Perform the search.
- Fetch commit extra data for each result. - Fetch commit extra data for each result.
@ -672,25 +672,17 @@ Now let's add ``SearchService`` to the container.
Edit ``containers.py``: Edit ``containers.py``:
.. code-block:: python .. code-block:: python
:emphasize-lines: 9,27-30 :emphasize-lines: 6,19-22
"""Application containers module.""" """Containers module."""
from dependency_injector import containers, providers 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 github import Github
from . import services, views from . import services
class ApplicationContainer(containers.DeclarativeContainer): class Container(containers.DeclarativeContainer):
"""Application container."""
app = flask.Application(Flask, __name__)
bootstrap = flask.Extension(Bootstrap)
config = providers.Configuration() config = providers.Configuration()
@ -705,8 +697,6 @@ Edit ``containers.py``:
github_client=github_client, github_client=github_client,
) )
index_view = flask.View(views.index)
Make the search work Make the search work
-------------------- --------------------