-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
uploaded serving a random image with a CGI script.md
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
date: 2024-11-12 | ||
title: serving a random image with a CGI script | ||
tags: cgi | ||
--- | ||
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: | ||
|
||
```bash | ||
#!/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. |