INNER CODE UNIT · Python

lifespan

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

    async def lifespan(_: FastAPI):
        nonlocal client
        if client is None:
            # trust_env=False: the API is a sibling service (same host or
            # network); routing its calls through the environment's
            # http_proxy turns a working setup into "Could not reach the
            # API" wherever a corporate proxy is configured.
            client = httpx.AsyncClient(base_url=fe.api_url, timeout=120.0, trust_env=False)
        try:
            yield
        finally:
            if owns_client and client is not None:
                await client.aclose()

    app = FastAPI(title=f"{fe.title} frontend", lifespan=lifespan)

    @app.get("/", response_class=HTMLResponse)
    async def index() -> HTMLResponse:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…