# Compiled Site Hosting & Docs Inventory

> When building a CMS, staging preview server, or local docs tooling on top of PraisonAIUI, use aiui.create_site_app() to serve compiled output directories with f

When building a CMS, staging preview server, or local docs tooling on top of PraisonAIUI, use `aiui.create_site_app()` to serve compiled output directories with full `aiui serve` parity and `aiui.list_docs_pages()` to read the exact compile-aligned page inventory.

## Serve a compiled site (`create_site_app`)

`aiui.create_site_app()` is the shared ASGI factory backing `aiui serve`. It serves canonical extensionless URLs, base paths, redirects, `Accept: text/markdown` twins, immutable `/assets` caching, and `content.docs.auth` password protection:

```python
import praisonaiui as aiui

# Static preview host for a CMS or staging release:
# - Optional live services (feedback votes, telemetry, MCP, Ask AI) stay OFF.
# - Canonical URLs, redirects, base paths, Markdown twins, and DocsAuth stay ON.
# - Explicit framing origin updates CSP frame-ancestors without allowing wildcards.
preview_app = aiui.create_site_app(
    "./aiui-output",
    mode="static",
    allow_frame_origin="http://127.0.0.1:8000",
)
```

### Parameters

| Parameter | Default | Description |
|---|---|---|
| `output` | required | Path to the compiled site directory produced by `aiui build` |
| `mode` | `"full"` | `"full"` enables optional live site services configured by the build (`aiui serve` default); `"static"` keeps feedback, telemetry, MCP, and Ask AI off |
| `cors_origins` | `None` | Optional list of CORS origins allowed for `GET` requests |
| `allow_frame_origin` | `None` | Explicit `http(s)://host[:port]` origin allowed to frame delivered pages (updates `frame-ancestors` and drops `X-Frame-Options`; wildcards `*` are rejected) |

### Security guarantees in `mode="static"`

- Password-protected builds (`content.docs.auth` / `aiui-access.json`) **always** enforce `DocsAuth` — a preview host never exposes closed pages.
- `allow_frame_origin` accepts only an explicit `http(s)://host[:port]` origin with no credentials, path, or CSP injection characters.

## Compile-aligned docs inventory (`list_docs_pages`)

`aiui.list_docs_pages()` loads `aiui.yaml` (or `aiui.template.yaml`) and runs the compiler's exact scan rules — including numbered-folder stripping, `index_files`, custom `routeBaseDocs`, `include`/`exclude`, `.aiuiignore`, expanded snippets and `{{variables}}`, generated OpenAPI pages, and redirects/aliases:

```python
import praisonaiui as aiui

for entry in aiui.list_docs_pages("./my-docs-repo"):
    print(entry.route, entry.kind, entry.editable, entry.source_path, entry.title)
```

Each entry is a frozen `DocPageInfo` dataclass:

| Field | Type | Description |
|---|---|---|
| `route` | `str` | Canonical URL path (e.g. `"/docs/guides/setup"`) |
| `title` | `str` | Effective title after snippet and `{{variable}}` expansion |
| `source_path` | `str \| None` | Checkout-relative POSIX path (e.g. `"docs/01-guides/02-setup.md"`) for `kind="editable"`, else `None` |
| `kind` | `"editable" \| "generated" \| "alias"` | Whether the route maps to editable Markdown, a compiler-generated page, or a redirect/index alias |
| `editable` | `bool` | `True` only when `kind == "editable"` |
| `target` | `str \| None` | Destination route when `kind == "alias"` |
| `hidden` | `bool` | Whether frontmatter set `hidden: true` |

`source_path` is returned only by this local Python API and is never emitted into public build manifests.

## Pairing with `preview_frame`

Combine `create_site_app(..., mode="static", allow_frame_origin=...)` with [`ui.preview_frame()`](https://ui.praison.ai/docs/components/preview-frame.md) to embed live themed site previews safely inside a CMS or workspace plugin.

## Related pages

- [Preview Frame](https://ui.praison.ai/docs/components/preview-frame.md)
- [Device Pairing](https://ui.praison.ai/docs/features/device-pairing.md)
- [Shell Hosting, Lifespan & Strict CSP](https://ui.praison.ai/docs/features/plugins/shell-hosting-and-csp.md)
