Files
Scanning the repository...
| Filesback | |
|---|---|
| .. | |
| backup_mp3 | |
| fixtures | |
| piclodio3 | |
| restapi | |
| tests | |
| utils | |
| .gitignore | |
| Dockerfile | |
| README.md | |
| entrypoint.sh | |
| manage.py | |
| requirements.txt |
README.mdPiclodio 3 backend
API doc
You can accees to API doc on the "/redoc" URL.
Development installation
System packages
sudo apt install sqlite3Create a dedicated python env
cd back virtualenv venv -p python3.10 source venvtest/bin/activateInstall python packages
pip3 install -r requirements.txtRun dev server
python3 manage.py runserverRun tests
python3 manage.py testProduction server
Switch the server to prod mode by editing the file
back/piclodio3/settings.pyand update the line that correspond to the debug
DEBUG = FalseRun the prod server
gunicorn --bind 0.0.0.0:8000 piclodio3.wsgi:applicationAutomatically at each startup with systemd (Prod)
Create and open a Systemd service file for Gunicorn with sudo privileges in your text editor:
sudo nano /etc/systemd/system/gunicorn.servicePlace the following content (update the WorkingDirectory path depending on your installation)
[Unit] Description=gunicorn daemon After=network.target[Service] User=pi Group=pi WorkingDirectory=/home/pi/piclodio3/back ExecStart=gunicorn --bind 0.0.0.0:8000 piclodio3.wsgi:application
[Install] WantedBy=multi-user.target
We can now start the Gunicorn service we created and enable it so that it starts at boot:
sudo systemctl daemon-reload sudo systemctl start gunicorn sudo systemctl enable gunicornThe backend API should now be accessible on the port 8000 of the server.