MCPcopy
hub / github.com/encode/starlette / hello_world

Function hello_world

tests/test_routing.py:653–661  ·  tests/test_routing.py::hello_world
(request: Request)

Source from the content-addressed store, hash-verified

651 items: list[int]
652
653 async def hello_world(request: Request) -> Response:
654 class="cm"># modifications to the state should not leak across requests
655 assert request.state.count == 0
656 class="cm"># modify the state, this should not leak to the lifespan or other requests
657 request.state.count += 1
658 class="cm"># since state.items is a mutable object this modification _will_ leak across
659 class="cm"># requests and to the lifespan
660 request.state.items.append(1)
661 return PlainTextResponse(class="st">"hello, world")
662
663 @contextlib.asynccontextmanager
664 async def lifespan(app: Starlette) -> AsyncIterator[State]:

Callers

nothing calls this directly

Calls 2

PlainTextResponseClass · 0.90
appendMethod · 0.45

Tested by

no test coverage detected