(request)
| 21 | |
| 22 | # -- handler-start -- |
| 23 | async 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 -- |
nothing calls this directly
no test coverage detected
searching dependent graphs…