> For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

# serve_static_files

> Serve static files from a directory alongside agent routes.

Serve static files (HTML, CSS, JS, images) from a local directory. Agent routes take priority
over static files, so requests matching a registered agent route are handled by the agent
first. Unmatched paths fall through to static file serving.

This method is useful for serving a web frontend alongside your agents -- for example,
an admin dashboard or a configuration UI.

Unlike mounting `StaticFiles` directly on the FastAPI app, this method integrates
correctly with agent route priority. Static files are served via the catch-all handler
that runs on startup.

## **Parameters**

**`directory`** `str` — required

Path to the directory containing static files. Must exist and be a valid directory.
Raises `ValueError` if the path does not exist or is not a directory.

---

**`route`** `str` — default: /

URL path prefix for static files. Use `"/"` to serve from the root. Directory requests
automatically resolve to `index.html` if it exists.

---

## **Returns**

`None`

## **Example**

```python {10}
from signalwire import AgentServer
from signalwire import AgentBase

support = AgentBase(name="support", route="/support")
support.set_prompt_text("You are a helpful assistant.")

server = AgentServer(port=3000)
server.register(support)

server.serve_static_files("./web")
server.run()
```

With this configuration:

| Request Path     | Served By                   |
| ---------------- | --------------------------- |
| `/support`       | SupportAgent                |
| `/support/swaig` | SupportAgent SWAIG endpoint |
| `/index.html`    | `./web/index.html`          |
| `/`              | `./web/index.html`          |
| `/css/style.css` | `./web/css/style.css`       |

Path traversal attempts (e.g., `/../etc/passwd`) are blocked. The resolved file path
must remain within the configured static directory.