- HTML 51.2%
- Python 48.8%
| parser | ||
| resources | ||
| templates | ||
| TM_T88XX_python@4a841b03f4 | ||
| .gitignore | ||
| .gitmodules | ||
| app.py | ||
| config.py | ||
| fonts.py | ||
| gen_image.py | ||
| html_gen.py | ||
| label_printer.service | ||
| LICENSE | ||
| parse_text.py | ||
| print.py | ||
| process_image.py | ||
| README.md | ||
| requirements.txt | ||
| todo | ||
| user_handler.py | ||
Setup
This guide assumes you have a raspberry pi, running raspberry pi os, and your have a user called "techinc". (If you have a different username, you are going to have to change some lines in label_printer.service)
Install
from the techinc home directory:
sudo apt update
sudo apt upgrade (Had some issues installing pillow through pip without this)
sudo apt install git libopenjp2-7 libfreetype6
git clone https://code.techinc.nl/amy/label_printer.git
navigate into the label_printer directory
python -m venv venv (this will take a while)
source venv/bin/activate
pip install --upgrade colorama flask pillow python-escpos pyusb
run python3 app.py to test if the webserver starts without errors (to reduce the need for troubleshooting later).
If you get something that looks like:
* Serving Flask app 'app'
* Debug mode: off
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on http://127.0.0.1:5000
Press CTRL+C to quit
This means things are working as expected. You can quit it by pressing ctrl+C
Installing the systemd daemon
sudo cp label_printer.service to /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable label_printer
sudo systemctl start label_printer
The interface should now be running on localhost:5000, which we need to route to the outside world in the next step
Setup the nginx
sudo apt install nginx
edit /etc/nginx/sites-available/default and change the contents of:
location / { }
to:
location / {
proxy_pass http://127.0.0.1:5000;
}
sudo systemctl restart nginx
Setup static ip on the pi
edit /etc/dhcpcd.conf and add:
static ip_address=10.209.10.2/24
static routers=10.209.10.254
static domain_name_servers=10.209.10.255
/etc/wpa_supplicant/wpa_supplicant.conf:
ctrl_interface=/run/wpa_supplicant
update_cunfig=1
wpa_passphrace ssid password >> /etc/wpa_supplicant/wpa_supplicant.conf
sudo apt install dhcpcd sudo ln -s /usr/share/dhcpcd/hooks/10-wpa_supplicant /usr/lib/dhcpcd/dhcpcd-hooks/ sudo systemctl enable dhcpcd