mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
request.url_vars property, closes #822
This commit is contained in:
parent
db660db463
commit
fac8e93815
5 changed files with 28 additions and 4 deletions
|
|
@ -42,6 +42,9 @@ The request object is passed to various plugin hooks. It represents an incoming
|
|||
``.args`` - MultiParams
|
||||
An object representing the parsed querystring parameters, see below.
|
||||
|
||||
``.url_vars`` - dictionary (str -> str)
|
||||
Variables extracted from the URL path, if that path was defined using a regular expression. See :ref:`plugin_register_routes`.
|
||||
|
||||
``.actor`` - dictionary (str -> Any) or None
|
||||
The currently authenticated actor (see :ref:`actors <authentication_actor>`), or ``None`` if the request is unauthenticated.
|
||||
|
||||
|
|
|
|||
|
|
@ -850,8 +850,8 @@ Return a list of ``(regex, async_view_function)`` pairs, something like this:
|
|||
import html
|
||||
|
||||
|
||||
async def hello_from(scope):
|
||||
name = scope["url_route"]["kwargs"]["name"]
|
||||
async def hello_from(request):
|
||||
name = request.url_vars["name"]
|
||||
return Response.html("Hello from {}".format(
|
||||
html.escape(name)
|
||||
))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue