runtimepy.net.server package#

Subpackages#

Submodules#

runtimepy.net.server.html module#

A module implementing HTML interfaces for web applications.

async runtimepy.net.server.html.html_handler(apps: dict[str, Callable[[Html, RequestHeader, ResponseHeader, bytes | None], Awaitable[Html]]], stream: TextIO, request: RequestHeader, response: ResponseHeader, request_data: bytes | None, default_app: Callable[[Html, RequestHeader, ResponseHeader, bytes | None], Awaitable[Html]] = None) None[source]#

Render an HTML document in response to an HTTP request.

runtimepy.net.server.json module#

A module implementing basic JSON-object response handling.

class runtimepy.net.server.json.Encoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]#

Bases: JSONEncoder

A custom JSON encoder.

default(o)[source]#

A simple override for default encoding behavior.

runtimepy.net.server.json.json_handler(stream: TextIO, request: RequestHeader, response: ResponseHeader, request_data: bytes | None, data: Dict[str, str | int | float | bool | None | Dict[str, str | int | float | bool | None] | List[str | int | float | bool | None]]) None[source]#

Create an HTTP response from some JSON object data.

Module contents#

A module implementing a server interface for this package.

class runtimepy.net.server.RuntimepyServerConnection(transport: Transport, protocol: QueueProtocol)[source]#

Bases: HttpConnection

A class implementing a server-connection interface for this package.

add_path(path: Path | str | None, front: bool = False) None[source]#

Add a path.

apps: dict[str, Callable[[Html, RequestHeader, ResponseHeader, bytes | None], Awaitable[Html]]] = {}#
class_paths: list[Path | str | None] = [PosixPath('.'), PosixPath('/home/vkottler/src/vkottler/workspace/runtimepy/runtimepy/data')]#
default_app: Callable[[Html, RequestHeader, ResponseHeader, bytes | None], Awaitable[Html]] | None = None#
favicon_data: bytes#
async get_handler(response: ResponseHeader, request: RequestHeader, request_data: bytes | None) bytes | None[source]#

Sample handler.

init() None[source]#

Initialize this instance.

json_data: Dict[str, str | int | float | bool | None | Dict[str, str | int | float | bool | None] | List[str | int | float | bool | None]] = {'test': {'a': 1, 'b': 2, 'c': 3}}#
log_paths() None[source]#

Log search paths.

paths: list[Path]#
try_file(path: Tuple[str, str | None], response: ResponseHeader) bytes | None[source]#

Try serving this path as a file directly from the file-system.

runtimepy.net.server.package_data_dir() Path[source]#

Get this package’s data directory.