add_directory

View as MarkdownOpen in Claude

Mount a new directory at a URL route. A leading / is added automatically if missing. Raises ValueError if the directory does not exist or the path is not a directory.

If the FastAPI app is already running, the new directory is mounted immediately.

Parameters

route
strRequired

URL path to mount at (e.g., "/docs"). A leading / is added automatically if missing.

directory
strRequired

Local directory path to serve.

Returns

None

Example

1from signalwire import WebService
2
3web = WebService(port=8002)
4web.add_directory("/audio", "./audio_files")
5web.add_directory("/images", "./public/images")
6web.start()