Skip to content

Repository files navigation

SWAKES Print

SWAKES Print

A self-hosted web interface and REST API for printing labels on a Brother QL-series printer from a Raspberry Pi.

Python Flask Raspberry Pi Brother QL Series MIT Licence

SWAKES.co.uk Β |Β  Blog Post

Overview

SWAKES Print is a web application that runs on a Raspberry Pi and gives you a browser-based interface to design and print labels directly to a Brother QL-series label printer over USB, WiFi, or Ethernet. It also exposes a REST API so other systems can trigger prints programmatically.

Β 

Inspired by brother_ql_web by Philipp Klaus β€” the original web interface for Brother QL printers. SWAKES Print was built on top of the brother_ql library that powers it, extending the concept with a fully custom UI, REST API, favourites, print history, vCard QR support, and a settings panel.

Β 

Screenshot

Screenshot

Screenshot

Screenshot

Β 

Features

πŸ–¨οΈ Label Printing

  • Print to any supported Brother QL-series printer over USB, WiFi, or Ethernet
  • Supports multiple label sizes: 62Γ—29mm, 29Γ—90mm, 62Γ—100mm, 12mm, 29mm
  • Live label preview canvas before printing
  • Zoom control on the preview
  • Print history β€” view the last 20 prints, each with a thumbnail and one-click Reprint button

πŸ“ Templates

  • Address Label β€” name and up to four address lines, each independently sized and bold
  • Food Label β€” name, date made, use-by date, and notes
  • QR Code β€” four QR types:
    • 🌐 Website β€” encode any URL
    • πŸ“ Text β€” encode plain text
    • πŸ“Ά WiFi β€” WPA/WPA2, WEP or open networks, with hidden SSID toggle
    • πŸ“‡ vCard β€” full contact card (name, organisation, phone, email, website)
  • Free Text β€” up to five independent text fields, each with custom font size, bold toggle, and drag-to-reposition

🎨 Design Tools

  • Per-field font size control and bold toggle
  • Drag elements to reposition on the canvas
  • Add and position images on the label β€” drag, resize, and move freely including outside label bounds
  • Upload and use custom fonts (.ttf / .otf)
  • QR label text displayed beside the QR code with custom sizing

⭐ Favourites

  • Save any label configuration as a named favourite
  • Load and restore a saved favourite instantly
  • Delete favourites you no longer need
  • Stored in favourites.json β€” survives service restarts

βš™οΈ Settings

  • Appearance β€” change app name, subtitle, accent colour, and logo via the UI (no code edits needed)
  • Fonts β€” upload custom fonts from within the settings panel
  • Consumables β€” save a URL to your label supplier for quick access
  • Export β€” download a zip of your full configuration (config, favourites, settings)
  • System β€” restart the label service from the browser
  • Printer β€” select your printer model, backend, and device address from the UI

πŸ“± Mobile Friendly

  • Responsive layout with Form / Preview tab switching on small screens
  • Touch-friendly input sizing
  • Prevents iOS auto-zoom on input focus

πŸ”Œ REST API

Trigger prints from any device on the network:

GET  /api/print?text=Hello&size=40
POST /api/print                          β€” multipart/form-data, image_file=<binary>
POST /api/print                          β€” JSON, {"image_base64": "..."}
GET  /api/print?image_url=https://…/img.png
GET  /api/print?template=Address+Label&name=John&address1=123+Main
GET  /api/print?template=QR+Code&qr_type=wifi&wifi_ssid=Net&wifi_password=pass

Β 

Supported Printers

SWAKES Print uses the brother_ql library and supports the following Brother QL-series printers. The printer model can be selected from Settings β†’ Printer without editing any config files.

Model Verified Notes
QL-500 βœ“ No compression, no auto-cut
QL-550 βœ“
QL-560 βœ“
QL-570 βœ“ Tested model
QL-580N
QL-650TD
QL-700 βœ“
QL-710W βœ“ WiFi capable
QL-720NW βœ“ WiFi/Ethernet
QL-800 βœ“ Black + red two-colour printing
QL-810W βœ“ WiFi, two-colour
QL-820NWB βœ“ WiFi/Bluetooth, two-colour
QL-1050 βœ“ Wide format (102mm)
QL-1060N βœ“ Wide format, network
QL-1100 βœ“ Wide format (102mm)
QL-1110NWB Wide format, WiFi/Bluetooth
QL-1115NWB Wide format, WiFi/Bluetooth

βœ“ = verified by brother_ql contributors. Unverified models may still work.

Connection backends supported:

  • pyusb β€” USB connection, works cross-platform
  • network β€” WiFi or Ethernet (tcp://192.168.x.x:9100)
  • linux_kernel β€” USB via /dev/usb/lp0, Linux only

Note: If your printer has an Editor Lite mode, disable it before connecting via USB β€” hold the button until the LED turns off.

Β 

Requirements

Hardware

  • Raspberry Pi (any model with USB; tested on Raspberry Pi 4)
  • Any supported Brother QL-series printer (see table above)
  • USB cable (or network connection for WiFi/Ethernet models)

Software

  • Raspberry Pi OS (Bullseye or later recommended)
  • Python 3.9+
  • pip and venv

Β 

Installation

1. Clone the repository

git clone https://github.com/pqpxo/swakes-print.git
cd swakes-print

2. Create and activate a virtual environment

python3 -m venv venv
source venv/bin/activate

3. Install dependencies

pip install flask pillow qrcode[pil] brother-ql requests pyusb

4. Configure the printer

Edit config.json to match your printer and label, or use Settings β†’ Printer in the UI after first run:

{
  "printer": {
    "model": "QL-570",
    "device": "usb://0x04f9:0x2042",
    "backend": "pyusb"
  },
  "label": {
    "default_size": "62x29",
    "supported_labels": ["62x29", "29x90", "62x100", "12", "29"],
    "canvas_width": 696,
    "canvas_height": 271,
    "default_font": "DejaVuSans.ttf",
    "default_font_size": 32
  }
}

To find your printer's USB vendor/product ID:

lsusb
# Look for Brother Industries β€” e.g. ID 04f9:2042

For WiFi/Ethernet models, set the backend and device accordingly:

{
  "printer": {
    "model": "QL-710W",
    "device": "tcp://192.168.1.50:9100",
    "backend": "network"
  }
}

5. USB permissions

Allow the Pi user to access the USB printer without sudo:

sudo nano /etc/udev/rules.d/99-brother-ql.rules

Add the following line (replace with your vendor/product ID):

SUBSYSTEM=="usb", ATTR{idVendor}=="04f9", ATTR{idProduct}=="2042", MODE="0666"

Then reload:

sudo udevadm control --reload-rules
sudo udevadm trigger

6. Run the application

python3 app.py

Open your browser to http://<pi-ip-address>:5000

Β 

Running as a systemd Service

To have SWAKES Print start automatically on boot:

1. Create the service file

sudo nano /etc/systemd/system/label_service.service
[Unit]
Description=SWAKES Print Label Service
After=network.target

[Service]
WorkingDirectory=/home/pi/swakes-print
ExecStart=/home/pi/swakes-print/venv/bin/python3 app.py
Restart=always
User=pi

[Install]
WantedBy=multi-user.target

2. Enable and start

sudo systemctl daemon-reload
sudo systemctl enable label_service
sudo systemctl start label_service

3. Allow browser-triggered restarts (optional)

To enable the Restart Service button in the Settings panel:

sudo nano /etc/sudoers.d/label_service

Add:

pi ALL=(ALL) NOPASSWD: /bin/systemctl restart label_service

Β 

Project Structure

swakes-print/
β”œβ”€β”€ app.py                  # Flask application and API routes
β”œβ”€β”€ printer_backend.py      # Brother QL printer interface
β”œβ”€β”€ config.json             # Printer and label configuration
β”œβ”€β”€ favourites.json         # Saved label favourites (auto-created)
β”œβ”€β”€ settings.json           # App settings (auto-created)
β”œβ”€β”€ print_history.json      # Print history log (auto-created)
β”œβ”€β”€ templates/
β”‚   └── index.html          # Main UI (single-page)
β”œβ”€β”€ static/
β”‚   β”œβ”€β”€ styles.css          # Dark navy theme
β”‚   └── logo.png            # App logo
β”œβ”€β”€ fonts/                  # Uploaded custom fonts (auto-created)
β”œβ”€β”€ uploads/                # Temporary image uploads (auto-created)
└── templates_data/         # Label template definitions
    β”œβ”€β”€ address_label.json
    └── food_label.json

Β 

Configuration Reference

Key Description Default
printer.model Brother printer model QL-570
printer.device USB or network device string usb://0x04f9:0x2042
printer.backend Print backend (pyusb, network, linux_kernel) pyusb
label.default_size Default label size 62x29
label.supported_labels Available sizes in the UI ["62x29",...]
label.default_font Font used if none selected DejaVuSans.ttf
label.default_font_size Default text size in points 32

Β 

Supported Label Sizes

Size Pixels (W Γ— H) Description
62x29 696 Γ— 271 Standard address label
29x90 306 Γ— 991 Tall narrow label
62x100 696 Γ— 1109 Large square label
12 142 Γ— 500 Thin tape
29 306 Γ— 500 Narrow label

Wide format models (QL-1050, QL-1060N, QL-1100+) support additional 102mm label widths. Add the relevant sizes to supported_labels in config.json to use them.

Β 

Troubleshooting

Printer shows Offline

  • Check the USB cable is connected and the printer is powered on
  • Verify the USB IDs in config.json match lsusb output
  • Check udev rules are applied: sudo udevadm trigger
  • For network printers, confirm the IP address and that port 9100 is reachable

Permission denied on USB

  • Run ls -la /dev/bus/usb/... and check the device permissions
  • Ensure the udev rule is in place and the user is in the correct group

Font not appearing in dropdown after upload

  • Font upload lives in Settings β†’ Fonts
  • After uploading, the font appears immediately in the dropdown without a page refresh

Restart button does nothing

  • Ensure the sudoers rule is in place (see above)
  • Check the service name matches exactly: label_service

Print history not recording

  • Ensure the service has write permission to the working directory
  • Check the service logs: sudo journalctl -u label_service -n 50

Changed printer model but nothing happened

  • After saving in Settings β†’ Printer, go to Settings β†’ System and restart the service

Licence

MIT β€” free to use, modify, and distribute. See LICENSE for details.


Built with ❀️ for the Raspberry Pi community

About

A self-hosted web interface and REST API for printing labels on a Brother QL-series printer from a Raspberry Pi.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages