vinegar.request_handler

Sub modules

file

Request handler that serves files from the file systems.

sqlite_update

Request handler that allows for making changes to an SQLite database.

Module API

Handlers that handle HTTP or TFTP requests.

Different handlers can be used for different purposes. The most common one is the vinegar.request_handler.file handler, which can serve resources from the file system.

All handler modules have in common that they must specify a get_instance_http or get_instance_tftp function (or both). Each of these functions takes a dict with configuration data as its only argument. These functions must return an instance of HttpRequestHandler or TftpRequestHandler. The key name in that configuration dict is reserved for use by the calling code and should be ignored by the request handler.

Request handlers are thread safe.

vinegar.request_handler.get_http_request_handler(name: str, config: Mapping[Any, Any]) HttpRequestHandler

Create an instance of the HTTP request handler with the specified name, using the specified configuration.

Parameters:

name – name of the request handler. If the name contains a dot, it is treated as an absolute module name. Otherwise it is treated as a name of one of the modules inside the vinegar.request_handler module.

Param:

config: configuration data for the request handler. The meaning of that data is up to the implementation of the request handler.

Returns:

newly created HTTP request handler.

vinegar.request_handler.get_tftp_request_handler(name: str, config: Mapping[Any, Any]) TftpRequestHandler

Create an instance of the TFP request handler with the specified name, using the specified configuration.

Parameters:

name – name of the request handler. If the name contains a dot, it is treated as an absolute module name. Otherwise it is treated as a name of one of the modules inside the vinegar.request_handler module.

Param:

config: configuration data for the request handler. The meaning of that data is up to the implementation of the request handler.

Returns:

newly created TFTP request handler.