ShtukbaseStandard
page/base/live.md

Live server

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.

Page fields (3)
icon⚡
port4322
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:

FieldWhat it meansDefault
portthe server port4322
runthe allow list of actions: lines "package action", for example lenses build; shtuk check is all the project's checksempty: pages run nothing
hostthe address; only 127.0.0.1, localhost, ::1 are allowed127.0.0.1

The token cannot be turned off. Norms: LIVE-R01 (only this computer), LIVE-R02 (writing by token), LIVE-R03 (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.

The package Live server puts this page at /base/live.md.Source text