This guide will get your ticket printer app deployed to Netlify via GitHub in under 10 minutes.
# If not already a git repo
git init
git add .
git commit -m "Initial commit"
# Push to GitHub (create repo first on GitHub.com)
git remote add origin https://github.com/YOUR_USERNAME/ticket-printer-app.git
git branch -M main
git push -u origin main- Go to netlify.com and sign up
- Click "Add new site" → "Import an existing project"
- Connect to GitHub and select your repo
- Build settings:
- Build command:
echo "No build required" - Publish directory:
frontend
- Build command:
- Click "Deploy site"
- Your site will be live in ~30 seconds! 🎉
# SSH into Raspberry Pi
ssh [email protected]
# Clone the repo
git clone https://github.com/YOUR_USERNAME/ticket-printer-app.git
cd ticket-printer-app/backend
# Install dependencies
pip3 install -r requirements.txt
# Find your printer
sudo lsusb # Note the IDs
# Run the API
python3 api.pyOption A: Quick Test with ngrok
# On Raspberry Pi
# Download ngrok
wget https://bin.equinox.io/c/bNyj1mQVY4c/ngrok-v3-stable-linux-arm.tgz
tar -xvzf ngrok-v3-stable-linux-arm.tgz
sudo mv ngrok /usr/local/bin/
# Run ngrok
ngrok http 5000
# Copy the https URL (e.g., https://abc123.ngrok.io)Option B: Persistent with Cloudflare Tunnel
# On Raspberry Pi
curl -L https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-arm -o cloudflared
chmod +x cloudflared
sudo mv cloudflared /usr/local/bin/
# Run tunnel
cloudflared tunnel --url http://localhost:5000
# Copy the https URLEdit frontend/index.html line 196:
const productionApiUrl = 'https://YOUR-TUNNEL-URL.ngrok.io';Or set Netlify environment variable:
- Netlify dashboard → Site settings → Environment variables
- Add:
REACT_APP_API_URL=https://YOUR-TUNNEL-URL.ngrok.io - Redeploy
- Open your Netlify site
- Fill out the form
- Submit a ticket
- Watch it print! 🎊
ticket-printer-app/
├── frontend/ # Static HTML for Netlify
│ └── index.html
├── backend/ # Flask API for Raspberry Pi
│ ├── api.py
│ └── requirements.txt
├── app.py # Original full-stack version
├── netlify.toml # Netlify config
└── GITHUB_DEPLOYMENT.md # Detailed guide
Edit backend/api.py:
USB_VENDOR = int(os.getenv('USB_VENDOR', '0x0416'), 16)
USB_PRODUCT = int(os.getenv('USB_PRODUCT', '0x5011'), 16)export PRINTER_TYPE=network
export NETWORK_HOST=192.168.1.100Frontend loads but can't print:
- Check ngrok is running
- Verify API URL in frontend code
- Test:
curl https://your-tunnel-url/health
Backend not running:
# Check status
sudo systemctl status ticket-printer
# View logs
sudo journalctl -u ticket-printer -f
# Restart
sudo systemctl restart ticket-printerPrinter issues:
# Test printer
python3 -c "from escpos.printer import Usb; p = Usb(0x0416, 0x5011); p.text('Test'); p.cut()"
# Fix permissions
sudo usermod -a -G lp,dialout pi
# Then log out and back in- Full deployment guide:
GITHUB_DEPLOYMENT.md - Raspberry Pi setup:
DEPLOYMENT.md - Original README:
README.md
✅ Beautiful web interface hosted on Netlify
✅ Accessible from anywhere
✅ Raspberry Pi backend handles printing
✅ Secure tunneling (ngrok or Cloudflare)
✅ Free hosting (Netlify free tier)
✅ Auto-deploy from GitHub
- Add API key authentication (see
GITHUB_DEPLOYMENT.md) - Use HTTPS (automatic with ngrok/Cloudflare)
- Consider rate limiting for production
- Keep your tunnel URL private
Questions? See the detailed guides:
GITHUB_DEPLOYMENT.md- Full deployment setupDEPLOYMENT.md- Raspberry Pi setup