Houdini 20.0 hwebserver

hwebserver.AsyncURLHandler class

The general purpose Async HTTP handler.

On this page

In cases where a general purpose url handler is desired over a builtin handler (i.e. @urlHandler or @apiFunction) the AsyncURLHandler class can be used. With the general purpose handler other RPC can be built on top (e.g. JSON RPC) while still being able to access all of Houdini. This handler allows for use with asyncio and is therefore Python3 only.



This example shows how to create a handler that will call a provided function when a new request comes in.

class URLCallbackHandler(hwebserver.AsyncURLHandler):
    def __init__(self, path, function, is_prefix=False):
        URLHandler.__init__(self, path, methods=['GET','POST'], allows_partial=is_prefix)
        self._function = function

    async def handle(self, request):
        if self._function is None:
            request.send(hwebserver.errorResponse(request, "Handler doesnt have a function attached.", 500))
        resp = await self._function(request)


See also



Starting and Stopping

Handling Web Requests and Returning Responses


  • WebSocket

    Base class for WebSocket support with the embedded server.

  • hwebserver.webSocket

    Decorator for registering WebSocket classes with Houdini’s web server.

API Calls

  • hwebserver.apiFunction

    Decorator for functions that can be called through an API endpoint on Houdini’s web server, returning JSON or binary responses.

  • hwebserver.APIError

    Raise this exception in apiFunction handlers to indicate an error.