Houdini 20.0 Python scripting hou hou.webServer

hou.webServer.run HOM function

Starts Houdini’s web server.

run(port=8008, debug=False, max_num_threads=4, in_background=None, reload_source_changes=None, max_in_memory_file_upload_size=None, max_request_size=None, settings=None, ports=[])

port

The port number to listen on. If this port is already in use or the process does not have permission to listen on it, the function raises hou.OperationFailed.

debug

If this is True, the server writes console log messages and displays stack traces for Python exceptions raised when handling requests. It also returns the stack traces in response bodies.

When running in hython, this also sets reload_source_changes to True.

You can check if the server is running in debug mode using hou.webServer.isInDebugMode().

max_num_threads

The maximum number of simultaneous worker threads created to handle concurrent requests.

Any calls in the hou package acquire a global lock, and Python handler functions must acquire the GIL, so handlers cannot usually run concurrently. The main speed benefit of multithreading comes when serving static files or making blocking I/O operations from Python that do not involve Houdini.

in_background

Whether the function should start the server in a separate thread. If you pass in_background=False, this function will never return unless the server is interrupted or server code calls hou.webServer.requestShutdown().

If in_background is None (the default value), it will be set to True in a graphical Houdini session and False otherwise.

reload_source_changes

If this is True, the server monitors all loaded Python source files and restarts the server whenever any of them change. This lets you edit your Python code and see the results without needing to stop and restart the server manually.

max_in_memory_file_upload_size

The maximum size, in bytes, of uploaded files that will be kept in RAM rather than written to a temp file. By default, the server will keep uploaded files that are less than 2.5 MB in memory, but write files larger than that to disk. This argument lets you override that threshold.

max_request_size

The maximum size of an HTTP request, in bytes. If this is None, the default value is 3 GB.

settings

Specify the settings file to add extra settings to the web server. Currently this only allows you to specify the CORS whitelist. This works similarly to djangos settings file.

ports

The extra ports the server should listen on.

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.