web frontend and python backend for picframe digital picture frame on raspberry pi
source /home/pi/venv_picframe/bin/activate
pip install flask pyyaml ruamel.yaml # only needed first time
python config.pyopen your browser http://192.168.50.117:5000 (replace the IP obviously)
make a new service:
mkdir -p /home/pi/.config/systemd/user
nano /home/pi/.config/systemd/user/picframe-web.servicepaste this in the service file:
[Unit]
Description=PicFrame Web UI
After=network.target
[Service]
WorkingDirectory=/home/pi
ExecStart=/home/pi/venv_picframe/bin/python /home/pi/config.py
Restart=always
RestartSec=5
# optional but recommended
Environment=PICFRAME_WEB_SECRET=change-this
[Install]
WantedBy=default.targetenable the service:
systemctl --user daemon-reload
systemctl --user enable picframe-web.service
systemctl --user start picframe-web.serviceautomatically start the service on boot:
sudo loginctl enable-linger picheck the service status:
systemctl status picframe-web.serviceread logs if there are problems:
journalctl --user -u picframe-web.service -fIf both the rpi and tv are on a smart switch together, you may wish for the rpi to tell the tv to turn on at boot time. If only the tv is on a smart switch proceed to the next section.
create systemd service file
sudo nano /etc/systemd/system/tv-on.servicepaste this in
[Unit]
Description=Turn on TV via HDMI-CEC
After=multi-user.target
[Service]
Type=oneshot
ExecStart=/bin/sh -c 'sleep 5 && echo "on 0" | cec-client -s -d 1'
[Install]
WantedBy=multi-user.targettell systemd about the service
sudo systemctl daemon-reexec
sudo systemctl daemon-reloadenable it at boot
sudo systemctl enable tv-on.servicetest it once
sudo systemctl start tv-on.servicefor an rpi on constant power and a tv on a smart switch you may wish to have the rpi turn the tv on automatically if there is power to it.
create systemd service
nano ~/.config/systemd/user/tv-wake.servicewith contents
[Unit]
Description=Periodic HDMI-CEC TV Wake
[Service]
ExecStart=/home/pi/picframe-server/tv_wake.sh
Restart=always
[Install]
WantedBy=default.targetenable it
systemctl --user daemon-reload
systemctl --user enable --now tv-wake.servicessh pi@192.168.50.117
# Then run:
sudo raspi-configGo to: Interface Options → VNC → Enable
Exit and reboot (optional but safe):
sudo rebootMost Raspberry Pi OS installs already include it, but just in case:
sudo apt update
sudo apt install realvnc-vnc-server realvnc-vnc-viewer
# Enable it:
sudo systemctl enable vncserver-x11-serviced
sudo systemctl start vncserver-x11-servicedscp "./configuration.yaml" pi@192.168.50.117:~/picframe_data/config/configuration.yaml
scp "./start_picframe.sh" pi@192.168.50.117:~/sudo nano /etc/fstab
# paste in the contents of /etc/fstab from this repo
sudo reboot