notes by alifeee profile picture tagged cgi (1) rss

return to notes / blog / website / weeknotes / linktree

here I may post some short, text-only notes, mostly about programming. source code.

tags: all (49) scripting (18) linux (5) android (4) bash (4) geojson (4) jq (4) obsidian (4) github (3) html (3) ............ see all (+74)

guestbook!

show all /
sign book

serving a random image with a CGI script # prev single next top

2024-11-12 • tags: cgi • 146 'words', 44 secs @ 200wpm

I made this because I have hundreds of images of myself and what I have been doing from BeReal.

I stopped using it because the company got big and evil (booo), so I requested all my data (images) and I (will soon) request them to remove that data.

But, for the meanwhile, I've been screwing around with it. I made a timelapse, but also fun is a random image picker.

I put all the images on my server, and made a very simple CGI script:

#!/bin/bash

file=$( (cd /var/www/; find images/ -type f -not -name "*index.html" \
  | sort --random-sort | head -n1) )

echo "HTTP/1.1 302 Found"
echo "Location: /${file}"
echo ""

now I can access /.../random.cgi and it redirects me to an image, served by nginx. Sweet.

I would like to write a bigger blog about CGI scripts in future.

back to top