WebService
WebService provides a standalone FastAPI-based HTTP server for serving static files alongside your SignalWire agents. It includes security features such as Basic authentication, CORS, path traversal prevention, file extension filtering, and configurable security headers.
Use WebService when your agent needs to serve audio files, web pages, or other static assets over HTTP/HTTPS.
Properties
app
The underlying FastAPI application instance. None if FastAPI is not installed.
port
The port the server listens on.
directories
Dictionary mapping URL route paths to local directory paths.
enable_directory_browsing
Whether directory listing is enabled for mounted directories.
max_file_size
Maximum file size in bytes that the server will serve (default: 100 MB).
enable_cors
Whether CORS middleware is enabled.
allowed_extensions
If set, only files with these extensions are served (e.g., [".html", ".css"]).
When None, all extensions except those in blocked_extensions are allowed.
blocked_extensions
File extensions and names that are never served. Defaults to
.env, .git, .gitignore, .key, .pem, .crt, .pyc, __pycache__,
.DS_Store, .swp.
security
The SecurityConfig instance
managing authentication and security headers.
The constructor also accepts basic_auth (Optional[tuple[str, str]]) and
config_file (Optional[str]) parameters. These are not exposed as public
instance attributes after initialization.