A web-based slideshow application to randomly display images from a directory. It is built with Rust, featuring a Rocket backend server and a Yew frontend framework.
I run it on a Raspberry pi, hooked up to a TV to have a slideshow of my favorite photos.
The project is divided into two main components:
backend/: Rocket-based server applicationfrontend/: Yew-based web application
- Rust (latest stable version)
- Cargo
- wasm-pack (for frontend development)
- Clone the repository:
git clone https://github.com/idc101/slideshow.git
cd rust-hw- Run:
cargo xtask run- The application will be available at
http://localhost:8000
The application can be configured through the following environment variables:
PICTURES_BASE: Slideshow directory path
docker build -t slideshow .
docker run -p 8000:8000 slideshow
This setup runs slideshow in docker and launches a fullscreen Chromium browser with the slideshow URL to display on HDMI.
- Install Chromium browser:
sudo apt-get update
sudo apt-get install chromium-browser- Install Slideshow:
docker build -t slideshow .
- Configure the slideshow to run on startup:
sudo nano /etc/rc.local
Add the following line before exit 0:
docker run -d -p 8000:8000 slideshow
- Restart the Raspberry Pi:
sudo reboot
- Create
~/bin/start-chromium.sh:
#!/bin/sh
set -e
CHROMIUM_TEMP=~/tmp/chromium
rm -Rf ~/.config/chromium/
rm -Rf $CHROMIUM_TEMP
mkdir -p $CHROMIUM_TEMP
chromium-browser \
--disable \
--disable-translate \
--disable-infobars \
--disable-suggestions-service \
--disable-save-password-bubble \
--disk-cache-dir=$CHROMIUM_TEMP/cache/ \
--user-data-dir=$CHROMIUM_TEMP/user_data/ \
--start-maximized \
--kiosk http://localhost:8000 &
- Launch Chromium on startup:
echo "@sh $HOME/bin/start-chromium.sh" >> ~/.config/lxsession/LXDE-pi/autostart
If you have a TV connected via HDMI, you can turn it on and off with CEC Control.
The backend provides the following API endpoints:
GET /api/image/<num>- Get a specific imageGET /api/image/<num>/metadata- Get metadata for a specific image
- Rocket - Web framework
- Tokio - Async runtime
- Yew - Frontend framework
- yew-router - Routing
- gloo-net - Network requests
- chrono - Time handling
- serde - Serialization/Deserialization