Start the server with this script instead of running python run.py directly:
./run_server.shThe script uses .venv/bin/python if it exists, otherwise it uses normal python.
When the server is running in the terminal:
Ctrl+Cstops the server like before.Ctrl+Alt+Rrestarts the server. this is useful after changingconfig.py.- If VS Code uses that shortcut, type
rsand press Enter instead.
The restart shortcut only works when the server was started with ./run_server.sh.
The Raspberry Pi should run the Flask server as a systemd service. This is the
normal Linux way to make a program start automatically in the background when
the Pi gets power.
The service file is here:
systemd/rubiks-web.serviceIt is set up for this project path:
/home/username/bachelorInstall and start it on the Raspberry Pi with:
./install_systemd_service.shAfter that, the web app starts by itself on every boot.
Useful commands:
sudo systemctl status rubiks-web.service
sudo systemctl restart rubiks-web.service
sudo systemctl stop rubiks-web.service
journalctl -u rubiks-web.service -fThe Flask app already listens on all network interfaces with 0.0.0.0, so other
computers on Ethernet can open:
http://<raspberry-pi-ip>:5000
If the Pi has hostname/mDNS enabled, this may also work:
http://raspberrypi.local:5000
For a direct cable with no router, give the Pi a fixed Ethernet IP, for example
192.168.50.1, and put the laptop on the same subnet. Then open:
http://192.168.50.1:5000