A website built from inside a notebook. Open it with
quilt notebook --serve examples/notebook/cafe.html.quilt, run the cells
top to bottom, and /site is what is left when the cells are taken away.
The SQL machine is a live sqlite3 on the session's own file, and the
Python kernel is told where that file is. One database, two machines.
route registers a handler in the kernel; the server proxies
/app/… to it as a feed. Returning a list answers JSON.
These run in this page's realm: their document is this
document, their handlers outlive the cell, and they reach the Python backend with
fetch. They are evaluated as JavaScript, so no type annotations here.
The first cell prints its view rather than assigning it. What a cell
prints is fed to the page, and markup carrying an id the page already has
redefines that element — so the page the server holds has the menu in it, and
/site does too. (Assigning to innerHTML would change
what this frame shows and nothing else: the page is the server's.)
The second adds behaviour. The handler goes on document, not on the
list: the page is a live document that cells keep redefining, and a listener bound
to an element it replaced would go with it.
no orders yet
Machines share nothing with each other; what they share is the page. A cell's output that carries an id the page already has redefines that element — so this Python cell writes the headline, wherever the headline happens to be.
py↖ count = db().execute("SELECT count(*) FROM menu").fetchone()[0] print(f'
…and an unquote that reaches the page reads it back, in the reading cell's own
language: \↙#title\↘ is a Python string here.