Houdini 19.0 hwebserver

hwebserver.URLHandler class

The general purpose 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 URLHandler 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.


The URLHandler is best suited for cases where the handler does not need to wait for other resources before responding. If the request needs to wait for other resources before responding the /hwebserver/AsyncURLHandler should be used instead.


This example shows how to create a handler that will call a provided function when a new request comes in. With this class a similar @urlHandler decorator can be created that uses this example.

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

    def handle(self, request):
        if self._function is None:
            return hwebserver.errorResponse(request, "Handler doesnt have a function attached.", 500)
        return self._function(request)


See also






  • WebSocket

    Base class for WebSocket support with the embedded server.

  • hwebserver.webSocket

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


  • 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.