Houdini 20.0 hwebserver

hwebserver.registerArchiveFile function

Tells Houdini’s web server to use the archived file as a virtual file directory.

registerArchiveFile(archive_file, url_prefix, port=-1)

When the server receives a request whose path starts with url_prefix, if the remaining part of the request path, is a file inside the archive file, the server will automatically serve that file to the client. The port can be optionally specified if the handler should run off a port other than the main port for the server.

Call this function before you call hwebserver.run, not from a URL handler.

For example, if you do this:

hwebserver.registerArchiveFile("/var/www/files/css.zip", "/css")

…and the client requests this server path:

/css/main.css

…and main.css file exists inside the css.zip file

…then the server will automatically serve the main.css file to the client without involving a Python handler.

You should try to set up the server so it serves any static files (files that are not generated dynamically from Houdini data, for example CSS and JavaScript files) this way, rather than in a Python handler. This virtual file system should only be used when file system space is limited. There is a performance hit to using this method compared to registering static directories.

Note

If a URL handler has a URL is more specific (matches more path parts) than the archive path prefix, the server will use the handler instead of archive lookup.

For example, even if you registered the archive directory above, if the client requested /archive/geo/foo.bgeo and you have a dynamic handler for /archive/geo, the server would use the handler instead of looking for a archive file.

See also

hwebserver

Classes

Starting and Stopping

Handling Web Requests and Returning Responses

WebSocket

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