Support non-async view functions, closes #867

This commit is contained in:
Simon Willison 2020-06-27 11:30:34 -07:00
commit 4b142862f2
4 changed files with 33 additions and 10 deletions

View file

@ -514,7 +514,7 @@ register_routes()
Register additional view functions to execute for specified URL routes.
Return a list of ``(regex, async_view_function)`` pairs, something like this:
Return a list of ``(regex, view_function)`` pairs, something like this:
.. code-block:: python
@ -554,6 +554,8 @@ The optional view function arguments are as follows:
``receive`` - function
The ASGI receive function.
The view function can be a regular function or an ``async def`` function, depending on if it needs to use any ``await`` APIs.
The function can either return a :ref:`internals_response` or it can return nothing and instead respond directly to the request using the ASGI ``send`` function (for advanced uses only).
Examples: `datasette-auth-github <https://github.com/simonw/datasette-auth-github>`__, `datasette-psutil <https://github.com/simonw/datasette-psutil>`__