mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-01-31 03:36:41 +03:00
26 lines
736 B
Python
26 lines
736 B
Python
"""Views module."""
|
|
|
|
from flask import request, render_template
|
|
from dependency_injector.wiring import Provide
|
|
|
|
from .services import SearchService
|
|
from .containers import Container
|
|
|
|
|
|
def index(
|
|
search_service: SearchService = Provide[Container.search_service],
|
|
default_query: str = Provide[Container.config.default.query],
|
|
default_limit: int = Provide[Container.config.default.limit.as_int()],
|
|
):
|
|
query = request.args.get('query', default_query)
|
|
limit = request.args.get('limit', default_limit, int)
|
|
|
|
repositories = search_service.search_repositories(query, limit)
|
|
|
|
return render_template(
|
|
'index.html',
|
|
query=query,
|
|
limit=limit,
|
|
repositories=repositories,
|
|
)
|