2026-03-28

Here's my capsule's tinylog aggregator: a Python cgi script using gtl

the finished tinylog aggregator page

see also this post about the script i use to generate my tinylog

My capsule is served by gmCapsule; presumably these examples will work fine with other cgi-capable servers too.

If you want to run either of these scripts, you'll also need to download GTL (thanks to @bacardi55 & @fab!):

https://codeberg.org/fab/gtl

I'm still very much a coding novice; my first approach was to re-use some functionality from previous gemini experiments; this script checks the client identity hash against a hard-coded value (i.e., check if it's me visiting the page), and if it's me visiting, runs gtl to request data from the subscribed list of tinylogs, and prints the output directly to the browser.

Other visitors would be served a file that only gets updated every few hours via a cron job. This served as a kind of rate-limit for everyone but me.

That crontab entry looked roughly like so:

EDIT, 2026-03-29:

Thanks to some reader feedback, here's an improved version of the cron entry; instead of running gtl right on the hour, roll a random number between 1 and 60 (I ran 'random.randint(1,60)' in python), and instead of listing all six 4-hour intervals, use "*/4" instead.

The script is pretty hacky, mostly I just fumbled around with it until it more or less worked.

Installation:

install gtl (link above)

copy script into your server's cgi folder

fill in the variables at the top

add a cron entry and run the cron job at least once.

Example 1, the cobbled-together version:

The next day I started actually searching for examples of how to get the output from subprocess.run() into a variable, and not long after that, decided to change my overall approach.

With this one, every visitor (including me) gets a freshly generated page, which is then cached, as long as the existing cached version was last modified at least 10 minutes prior to the visit. Otherwise the cached version gets served. No need for a cron job, no need to check a client cert in order to avoid having my server be used as a 'force multiplier', generating masses of requests to other people's servers.

I also made a couple small tweaks to how the output gets printed to the screen. Much happier with this version.

Installation:

install gtl (link at top of post)

copy script to your server's cgi folder

fill in the variables at the top of main()

Example 2, the better version:

Thanks for reading! Feedback and/or questions are welcome :)

Proxied content from gemini://gemini.patatas.ca/posts/tinylog-aggregator.gmi (external content)

Gemini request details:

Original URL
gemini://gemini.patatas.ca/posts/tinylog-aggregator.gmi
Status code
Success
Meta
text/gemini
Proxied by
kineto

Be advised that no attempt was made to verify the remote SSL certificate.