start

View as MarkdownOpen in Claude

Start the HTTP server. Blocks until the server is stopped. Raises RuntimeError if FastAPI or uvicorn are not available.

When ssl_cert and ssl_key are provided, the server starts with HTTPS. Otherwise, SSL configuration is loaded from the SecurityConfig environment variables.

Parameters

host
strDefaults to 0.0.0.0

Host address to bind to.

port
Optional[int]

Port to bind to. Defaults to the port set in the constructor.

ssl_cert
Optional[str]

Path to an SSL certificate file. Overrides environment-based SSL configuration.

ssl_key
Optional[str]

Path to an SSL key file. Overrides environment-based SSL configuration.

Returns

None — This method blocks and does not return until the server is stopped.

Example

1from signalwire import WebService
2
3web = WebService(
4 port=8002,
5 directories={"/recordings": "./recordings"},
6 basic_auth=("admin", "secret"),
7 enable_directory_browsing=True
8)
9web.start(host="0.0.0.0", port=8002)

With HTTPS

1from signalwire import WebService
2
3web = WebService(
4 port=443,
5 directories={"/assets": "./public"}
6)
7web.start(ssl_cert="cert.pem", ssl_key="key.pem")