package page→ /base/live.md
pages/base/live.md
41 lines, 2.0 KB. As a page.
- ---
- type: Page
- title: "Live server"
- icon: "⚡"
- description: "Settings of the project's live server: the port and the allow list of actions that pages may run. How to start the server and how to make your own interactive page."
- port: 4322
- run: []
- ---
- The live server opens a project in a browser so that lenses and your own HTML pages can change records: move cards, change fields and text, create records, run allowed actions. The server works only on this computer.
- ## Starting
- ```
- shtuk run live serve # the port from this page
- shtuk run live serve --port 4400
- ```
- The server prints two links. The link with `?token=…` turns on editing: the browser remembers the session token in a cookie. The link without a token is read-only. A new start is a new token. To stop, press Ctrl-C.
- Open lenses update themselves: the server watches the project's files, rebuilds the lens data after an edit and tells the pages to re-read it.
- ## Settings
- The fields in the header of this page:
- | Field | What it means | Default |
- |---|---|---|
- | `port` | the server port | 4322 |
- | `run` | the allow list of actions: lines "package action", for example `lenses build`; `shtuk check` is all the project's checks | empty: pages run nothing |
- | `host` | the address; only `127.0.0.1`, `localhost`, `::1` are allowed | 127.0.0.1 |
- The token cannot be turned off. Norms: [LIVE-R01](/norms/rules/live/LIVE-R01.md) (only this computer), [LIVE-R02](/norms/rules/live/LIVE-R02.md) (writing by token), [LIVE-R03](/norms/rules/live/LIVE-R03.md) (the allow list).
- ## Your own interactive page
- 1. `shtuk run live app` places the example, a task board with the buttons "Take", "Done" and "Check project", in `work/tasks-app.html`. For another place: `shtuk run live app <path.html>`.
- 2. For the "Check project" button to work, add `shtuk check` to `run:` of this page.
- 3. Open the page by the server's link with the token and edit it like ordinary HTML: the buttons call the server's API through `fetch`.
- What the API can do, with examples, is on the package page: `.shtukbase/packages/live/package.md`.