Clone this project.
Create a virtual environment in the project folder:
python3 -m venv ./venv
Activate the virtual environment:
source venv/bin/activate
Install the required packages:
pip install -r requirements.txt
pip install uwsgi
Manually run with UWSGI for testing:
uwsgi --ini plantwatering.ini
Test with curl:
curl -u username:password localhost:8080
Use cloudflared to make the website publicly accessible: https://pimylifeup.com/raspberry-pi-cloudflare-tunnel/ (Make sure to also follow the steps to start it on boot)
To start uwsgi on boot:
sudo nano /etc/systemd/system/plantwatering.service
with content:
[Unit]
Description=uWSGI instance to serve the plantwatering project
After=network.target
[Service]
User=pi
Group=pi
WorkingDirectory=/home/pi/Desktop/plantwatering-flask
ExecStart=/home/pi/Desktop/plantwatering-flask/venv/bin/uwsgi --ini plantwatering.ini
# default is 90. For some reason sometimes stopping the service doesn't work until that timeout triggers a kill
TimeoutStopSec=15
[Install]
WantedBy=multi-user.target
sudo systemctl enable plantwatering
sudo systemctl start plantwatering