INNER CODE UNIT · Python

create_app

pathwaycom/llm-app · serviette/frontend/main.py:42

def create_app(config: ServietteConfig, *, client: httpx.AsyncClient | None = None) -> FastAPI:
    """Build the frontend app.

    ``client`` can be injected (tests provide an httpx client backed by a mock
    transport); otherwise one is created against ``frontend.api_url``.
    """

    config.for_frontend()
    fe = config.frontend
    assert fe is not None  # guaranteed by for_frontend()
    index_html = load_index(fe.title)
    owns_client = client is None

    @asynccontextmanager
    async def lifespan(_: FastAPI):
        nonlocal client
        if client is None:
            # trust_env=False: the API is a sibling service (same host or

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…