Your own guestbook¶
You can put this guestbook on your own site for FREE. It's a folder of plain files for the page and one Python file for the server, and the server needs nothing but Python 3.8 or newer, with no packages to install.
The two pieces¶
- The page is everything in
app/. Put it wherever your site's files are, for example in aguestbook/folder. It talks to the server atapi/next to itself, so/guestbook/talks to/guestbook/api/. - The server is
server/guestbook.py. It listens on127.0.0.1only, which means your web server has to passapi/along to it.
Settings¶
The server reads four settings from its environment:
| Setting | What it's for | Default |
|---|---|---|
GUESTBOOK_DATA |
the folder for entries.json, counter.json and the log |
data/ next to the repo |
GUESTBOOK_PORT |
the port it listens on | 8452 |
GUESTBOOK_PUBLIC |
the page's public address, for the links in your messages | http://127.0.0.1:8452 |
GUESTBOOK_NOTIFY |
a command it runs as <command> "Guestbook" "<message>" for each new entry |
none (the log only) |
For the notify command, anything that sends you a message works: a script that calls signal-cli, ntfy, a
Telegram bot or plain mail.
With Caddy¶
handle_path /guestbook/api/* {
reverse_proxy 127.0.0.1:8452
}
The page folder is served like any other files. If you put Cloudflare in front, the server reads the visitor's
address from CF-Connecting-IP for the rate limit, and otherwise from X-Forwarded-For.
Keeping it running¶
A small systemd unit is the easiest way:
[Service]
Environment=GUESTBOOK_DATA=/var/lib/guestbook
Environment=GUESTBOOK_PUBLIC=https://example.com/guestbook
Environment=GUESTBOOK_NOTIFY=/usr/local/bin/notify-me
ExecStart=/usr/bin/python3 /opt/guestbook/guestbook.py
Restart=always
Then open your page, sign it once yourself, and check that the message with the link reaches you. If it doesn't, the log file in the data folder says why.
Basically, copy two things, add three lines to your web server, and you have a guestbook.