MCPcopy Create free account
hub / github.com/mongodb/motor / page_handler

Function page_handler

doc/examples/aiohttp_example.py:23–36  ·  view source on GitHub ↗
(request)

Source from the content-addressed store, hash-verified

21
22# -- handler-start --
23async def page_handler(request):
24 # If the visitor gets "/pages/page-one", then page_name is "page-one".
25 page_name = request.match_info.get("page_name")
26
27 # Retrieve the long-lived database handle.
28 db = request.app["db"]
29
30 # Find the page by its unique id.
31 document = await db.pages.find_one(page_name)
32
33 if not document:
34 return web.HTTPNotFound(text=f"No page named {page_name!r}")
35
36 return web.Response(body=document["body"].encode(), content_type="text/html")
37
38
39# -- handler-end --

Callers

nothing calls this directly

Calls 1

getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…