Sign inSign up

daskaesebrot/randhaj

By daskaesebrot

Updated 6 days ago

A web service that shows you a random image

Image
0

10K+

daskaesebrot/randhaj repository overview

randhaj logo

randhaj

A web service that displays a random image, made primarily to show random pictures of Blåhaj on my website kaesebrot.eu/blahaj :)

Features

  • on-the-fly cached image generation for different resolutions
  • deterministic image IDs that are calculated from the pixel values, not the file bytes: an image will always receive the same ID
  • privacy-focused: all EXIF tags are stripped from hosted images
  • Open Graph protocol integration for link previews
  • inotify-based watchfolder support: images are automatically added/removed when copied/deleted to/from the input folder
  • optimized slim page responses for crawlers (return just Open Graph tags and the html header)
  • gallery page
  • pageable image API
  • a submissions page
  • responsive page UI with focus on mobile usage
  • as few HTML/CSS/Javascript dependencies as possible

Deployment

The service is available as a container on Docker hub: https://hub.docker.com/r/daskaesebrot/randhaj

docker pull daskaesebrot/randhaj

Configuration

You may configure the web service via environment variables.

Environment variables
Variable nameDescriptionDefault valueRequired?
RANDHAJ_IMAGE_DIRWhere to load the images to display from. Supperted file types: jpg and pngassets/images (in Docker: /var/assets)No
RANDHAJ_CACHE_DIRWhere to save the cached images (converted/resized)cacheNo
RANDHAJ_CACHE_DB_FILEFile path for the cache SQLite database. Set this to :memory: to disable caching across service restarts.<RANDHAJ_CACHE_DIR>/.randhaj-cache.dbNo
RANDHAJ_SUBMISSIONS_DIRWhere to save the submitted images (converted/resized)submissionsNo
RANDHAJ_SUBMISSIONS_DIR_DISK_USAGE_LIMITMaximum disk usage, above which submissions are blocked (float value between 0.0 and 1.0)0.9No
RANDHAJ_SITE_TITLEThe site title to useRandom imageNo
RANDHAJ_SITE_EMOJIThe site emoji (used for the favicon and title)🦈No
RANDHAJ_DEFAULT_CARD_IMAGEThe image ID to use as the Open Graph thumbnail for the root view (/)The (alphabetically) first IDNo
RANDHAJ_LOG_LEVELThe log level (uses UVICORN_LOG_LEVEL as fallback if unset, then uses default value)INFONo
RANDHAJ_MAX_INITIAL_CACHE_GENERATOR_WORKERSHow many maximum workers to use for generating the initial image cache4No
FORWARDED_ALLOW_IPSReverse proxies to trust (see Uvicorn docs)127.0.0.1No
Additional HTML head/footer tags

If you'd like to add additional tags in the <head> section or <footer> section of the rendered page, you may create the following files in the folder templates/custom:

TagFilenameRemarks
<head>head.htmlInserted before closing <head> tag
<footer>footer.htmlInserted after opening <footer> tag

Logo attribution

The logo and favicon used in this project were created by Merlin, a very talented friend of mine! Thank you so much for the cute logo!

Follow him on Instagram: @itsjustmerlin

Open Source License Attribution

This application uses Open Source components. You can find the source code of their open source projects along with license information below. We acknowledge and are grateful to these developers for their contributions to open source.

FastAPI
Pillow
Jinja
inotify
SQLAlchemy
Flake8
pytest

Tag summary

Content type

Image

Digest

sha256:513340567

Size

97.4 MB

Last updated

6 days ago

docker pull daskaesebrot/randhaj