| Crates.io | random-image-server |
| lib.rs | random-image-server |
| version | 0.2.0 |
| created_at | 2025-07-26 23:38:26.385461+00 |
| updated_at | 2025-07-26 23:38:26.385461+00 |
| description | A simple image server that serves random images from a preconfigured list of paths and URLs. |
| homepage | |
| repository | https://github.com/AnthonyMichaelTDM/random-image-server |
| max_upload_size | |
| id | 1769531 |
| size | 235,831 |
A simple http server that returns a random image from a pre-configured directory.
The server exposes the following endpoints:
GET /health: Returns a 200 OK response to indicate the server is running.GET /random: Returns a random image from the configured sources.GET /sequential: Returns the next image in sequence from the configured sources.config.toml file.The server can be configured using a config.toml file. The configuration file should be placed in the same directory as the binary.
The configuration file should have the following structure:
[server]
port = 8080 # The port the server will listen on
host = "0.0.0.0" # The host the server will bind to
log_level = "info" # The log level for the server, can be "error", "warn", "info", "debug", or "trace"
sources = [
"/path/to/image.jpg",
"/path/to/another/image.png",
"/path/to/image/directory",
"http://example.com/images"
]
[cache]
# Configuration for the cache backend
backend = "file_system" # The type of cache backend to use, can be "in_memory" or "file_system"
You can also override the configuration using environment variables. The environment variables should be prefixed with RANDOM_IMAGE_SERVER_, and the keys should be in uppercase with underscores instead of dots. For example, to set the port, you can use the environment variable RANDOM_IMAGE_SERVER_PORT.
follow instructions in the Release page for the latest release, which involves curling a script and piping it to sh, or install from crates.io:
cargo install random-image-server
I don't know how to publish the docker image to a registry without having to pay for it, so you will have to build the image yourself. So, you'll need to clone the repository and build the image yourself.
You can build and run the server as a docker container using the provided Dockerfile and docker-compose file.
config.toml file with your desired configuration, and update the compose.yml file to mount the configuration file and any image directories you want to serve.docker compose build:docker compose up:This will start the server and expose it on port 8080. You can access the server at http://localhost:8080.
After downloading the binary:
/usr/local/bin/random-image-serverrandom-image-server.service file from the repo and place it in /etc/systemd/system/config.toml file in /etc/random-image-server/config.toml, and edit it to your liking.sudo systemctl enable random-image-server.service
sudo systemctl start random-image-server.service
You can check the status of the service with:
sudo systemctl status random-image-server.service
and view the logs with:
sudo journalctl -u random-image-server.service