Houdini 20.0 Python scripting hou hou.webServer

hou.webServer.errorResponse HOM function

Generates a Response object representing an HTTP error.

errorResponse(request, error_message, status, use_heading): hou.webServer.Response

request

The Request object passed to the URL handler or API function.

(The function checks the request to see if the client wants a JSON response. If the client provided an Accept: application/json, */* header, this returns the JSON response {"error": error_message}, and error_message may be any JSON-encodable value.)

error_message

Error message to display to the user.

(This can be any JSON-encodable value if you know the response will be JSON rather than HTML.)

use_heading

If the response is an HTML page (instead of JSON), automatically wrap the error_message in an <h1> element.

import hou


@hou.webServer.urlHandler("/node/info/", is_prefix=True)
def node_info(request):
    path = request.path()
    assert path.startswith("/node/info")
    node_path = path[10:]
    node = hou.node(node_path)
    if node is None:
        return hou.webServer.errorResponse(request, "Resource not found", 404)
    # ...
See also

hou.webServer

Classes

Starting and Stopping

Handling Web Requests and Returning Responses

API Calls

  • hou.webServer.apiFunction()

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

  • hou.webServer.APIError

    Raise this exception in apiFunction handlers to indicate an error.