betty.serve module

Provide the Serve API to serve resources within the application.

class betty.serve.AppServer[source]

Bases: Server

A web server for a Betty application.

Parameters:

app (betty.app.App)

__init__(app: betty.app.App) None[source]
Parameters:

app (betty.app.App)

static get(app: betty.app.App) betty.serve.AppServer[source]

Get a web server for the given Betty application.

Parameters:

app (betty.app.App)

Return type:

betty.serve.AppServer

async start() None[source]

Start the server.

Return type:

None

class betty.serve.BuiltinAppServer[source]

Bases: AppServer

A built-in server for a Betty application.

Parameters:

app (betty.app.App)

__init__(app: betty.app.App) None[source]
Parameters:

app (betty.app.App)

classmethod label() betty.locale.Str[source]

Get the server’s human-readable label.

Return type:

betty.locale.Str

property public_url: str

The server’s public URL.

async start() None[source]

Start the server.

Return type:

None

async stop() None[source]

Stop the server.

Return type:

None

class betty.serve.BuiltinServer[source]

Bases: Server

A built-in server for a WWW directory.

Parameters:
__init__(www_directory_path: pathlib._local.Path, *, root_path: str | None = None, localizer: betty.locale.Localizer) None[source]
Parameters:
classmethod label() betty.locale.Str[source]

Get the server’s human-readable label.

Return type:

betty.locale.Str

property public_url: str

The server’s public URL.

async start() None[source]

Start the server.

Return type:

None

async stop() None[source]

Stop the server.

Return type:

None

exception betty.serve.NoPublicUrlBecauseServerNotStartedError[source]

Bases: ServerNotStartedError

A public URL is not yet available because the server has not (fully) started yet.

__init__()[source]
exception betty.serve.OsError[source]

Bases: UserFacingError, OSError

Raised for I/O errors.

Parameters:

message (betty.locale.Localizable)

class betty.serve.Server[source]

Bases: object

Provide a development web server.

Parameters:

localizer (betty.locale.Localizer)

__init__(localizer: betty.locale.Localizer)[source]
Parameters:

localizer (betty.locale.Localizer)

async assert_available() None[source]

Assert that this server is available.

Return type:

None

classmethod label() betty.locale.Str[source]

Get the server’s human-readable label.

Return type:

betty.locale.Str

classmethod name() str[source]

Get the server’s machine name.

Return type:

str

property public_url: str

The server’s public URL.

async show() None[source]

Show the served site to the user.

Return type:

None

async start() None[source]

Start the server.

Return type:

None

async stop() None[source]

Stop the server.

Return type:

None

exception betty.serve.ServerNotStartedError[source]

Bases: RuntimeError

Raised when a web server has not (fully) started yet.

class betty.serve.ServerProvider[source]

Bases: object

Provide one or more web servers.

property servers: Sequence[Server]

Provide one or more web servers.