From e7738383e9ae52a9785d6bb4eda129213acc6ec8 Mon Sep 17 00:00:00 2001 From: leejet Date: Mon, 16 Mar 2026 00:20:17 +0800 Subject: [PATCH] update server readme --- examples/server/README.md | 89 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/examples/server/README.md b/examples/server/README.md index 38deff6..8aa2158 100644 --- a/examples/server/README.md +++ b/examples/server/README.md @@ -1,3 +1,92 @@ +# Frontend + +## Build with Frontend + +The server can optionally build the web frontend and embed it into the binary as `gen_index_html.h`. + +### Requirements + +Install the following tools: + +* **Node.js** ≥ 22.18 + https://nodejs.org/ + +* **pnpm** ≥ 10 + Install via npm: + +```bash +npm install -g pnpm +``` + +Verify installation: + +```bash +node -v +pnpm -v +``` + +### Install frontend dependencies + +Go to the frontend directory and install dependencies: + +```bash +cd examples/server/frontend +pnpm install +``` + +### Build the server with CMake + +Enable the frontend build option when configuring CMake: + +```bash +cmake -B build -DSD_SERVER_BUILD_FRONTEND=ON +cmake --build build --config Release +``` + +If `pnpm` is available, the build system will automatically run: + +``` +pnpm run build +pnpm run build:header +``` + +and embed the generated frontend into the server binary. + +## Frontend Repository + +The web frontend is maintained in a **separate repository**, https://github.com/leejet/stable-ui. + +If you want to modify the UI or frontend logic, please submit pull requests to the **frontend repository**. + +This repository (`stable-diffusion.cpp`) only vendors the frontend periodically. Changes from the frontend repo are synchronized: + +* approximately **every 1–2 weeks**, or +* when there are **major frontend updates** + +Because of this, frontend changes will **not appear here immediately** after being merged upstream. + +## Using an external frontend + +By default, the server uses the **embedded frontend** generated during the build (`gen_index_html.h`). + +You can also serve a custom frontend file instead of the embedded one by using: + +```bash +--serve-html-path +``` + +For example: + +```bash +sd-server --serve-html-path ./index.html +``` + +In this case, the server will load and serve the specified `index.html` file instead of the embedded frontend. This is useful when: + +* developing or testing frontend changes +* using a custom UI +* avoiding rebuilding the binary after frontend modifications + # Run ```