betty.serve module - Betty 0.4.0a1 documentation

Hide navigation sidebar
Hide table of contents sidebar
Skip to content
Back to top
View this page
Toggle table of contents sidebar

# betty.serve module

Provide the Serve API to serve resources within the application.

class betty.serve.AppServer

  Bases: `Server`

  A web server for a Betty application.

  Parameters:

    app (`betty.app.App`)

  __init__(app: betty.app.App) → None
    Parameters:

      app (`betty.app.App`)

  async start() → None

    Start the server.

    Return type:

      `None`

class betty.serve.BuiltinAppServer

  Bases: `AppServer`

  A built-in server for a Betty application.

  Parameters:

    app (`betty.app.App`)

  __init__(app: betty.app.App) → None
    Parameters:

      app (`betty.app.App`)

  classmethod label() → betty.locale.Localizable

    Get the server’s human-readable label.

    Return type:

      `betty.locale.Localizable`

  property public_url: str

    The server’s public URL.

  async start() → None

    Start the server.

    Return type:

      `None`

  async stop() → None

    Stop the server.

    Return type:

      `None`

class betty.serve.BuiltinServer

  Bases: `Server`

  A built-in server for a WWW directory.

  Parameters:

    - www_directory_path (`pathlib.Path`)

    - root_path (`str` | `None`)

    - localizer (`betty.locale.Localizer`)

  __init__(www_directory_path: pathlib.Path, *, root_path: str | None = None, localizer: betty.locale.Localizer) → None
    Parameters:

      - www_directory_path (`pathlib.Path`)

      - root_path (`str` | `None`)

      - localizer (`betty.locale.Localizer`)

  classmethod label() → betty.locale.Localizable

    Get the server’s human-readable label.

    Return type:

      `betty.locale.Localizable`

  property public_url: str

    The server’s public URL.

  async start() → None

    Start the server.

    Return type:

      `None`

  async stop() → None

    Stop the server.

    Return type:

      `None`

exception betty.serve.NoPublicUrlBecauseServerNotStartedError

  Bases: `ServerNotStartedError`

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

  __init__()

exception betty.serve.OsError

  Bases: `UserFacingError`, `OSError`

  Raised for I/O errors.

  Parameters:

    message (`betty.locale.Localizable`)

class betty.serve.Server

  Bases: `object`

  Provide a development web server.

  Parameters:

    localizer (`betty.locale.Localizer`)

  __init__(localizer: betty.locale.Localizer)
    Parameters:

      localizer (`betty.locale.Localizer`)

  async assert_available() → None

    Assert that this server is available.

    Return type:

      `None`

  classmethod label() → betty.locale.Localizable

    Get the server’s human-readable label.

    Return type:

      `betty.locale.Localizable`

  classmethod name() → str

    Get the server’s machine name.

    Return type:

      `str`

  property public_url: str

    The server’s public URL.

  async show() → None

    Show the served site to the user.

    Return type:

      `None`

  async start() → None

    Start the server.

    Return type:

      `None`

  async stop() → None

    Stop the server.

    Return type:

      `None`

exception betty.serve.ServerNotStartedError

  Bases: `RuntimeError`

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