ShtukbaseStandard
package page→ /base/live.md

pages/base/live.md

41 lines, 2.0 KB. As a page.

  1. ---
  2. type: Page
  3. title: "Live server"
  4. icon: "⚡"
  5. 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."
  6. port: 4322
  7. run: []
  8. ---
  9. 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.
  10. ## Starting
  11. ```
  12. shtuk run live serve # the port from this page
  13. shtuk run live serve --port 4400
  14. ```
  15. 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.
  16. 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.
  17. ## Settings
  18. The fields in the header of this page:
  19. | Field | What it means | Default |
  20. |---|---|---|
  21. | `port` | the server port | 4322 |
  22. | `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 |
  23. | `host` | the address; only `127.0.0.1`, `localhost`, `::1` are allowed | 127.0.0.1 |
  24. 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).
  25. ## Your own interactive page
  26. 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>`.
  27. 2. For the "Check project" button to work, add `shtuk check` to `run:` of this page.
  28. 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`.
  29. What the API can do, with examples, is on the package page: `.shtukbase/packages/live/package.md`.