Open Source Digital Signage [SAFE]
CMD ["python", "qr_signage_api.py"]
with app.app_context(): db.create_all() def generate_qr_base64(url): qr = qrcode.QRCode(version=1, box_size=10, border=4) qr.add_data(url) qr.make(fit=True) img = qr.make_image(fill_color="black", back_color="white") buffered = BytesIO() img.save(buffered, format="PNG") return base64.b64encode(buffered.getvalue()).decode() Get current active QR for display @app.route('/api/current-qr', methods=['GET']) def get_current_qr(): active_qrs = QRContent.query.filter_by(is_active=True).all() open source digital signage
<script> const API_URL = 'http://localhost:5000'; let chart = null; async function loadAnalytics() const response = await fetch(`$API_URL/api/analytics`); const data = await response.json(); document.getElementById('totalScans').textContent = data.total_scans; document.getElementById('scansLastHour').textContent = data.scans_last_hour; document.getElementById('activeCount').textContent = data.qr_performance.length; // Update chart if (chart) chart.destroy(); const ctx = document.getElementById('performanceChart').getContext('2d'); chart = new Chart(ctx, type: 'bar', data: labels: data.qr_performance.map(p => p.name), datasets: [ label: 'Number of Scans', data: data.qr_performance.map(p => p.scans), backgroundColor: '#667eea' ] ); async function addQRContent() const data = name: document.getElementById('qrName').value, url: document.getElementById('qrUrl').value, description: document.getElementById('qrDesc').value, display_duration: parseInt(document.getElementById('qrDuration').value) ; const response = await fetch(`$API_URL/api/qr-content`, method: 'POST', headers: 'Content-Type': 'application/json' , body: JSON.stringify(data) ); if (response.ok) alert('QR content added successfully!'); location.reload(); // Auto-refresh every 10 seconds loadAnalytics(); setInterval(loadAnalytics, 10000); </script> </body> </html> # Dockerfile FROM python:3.9-slim WORKDIR /app CMD ["python", "qr_signage_api
COPY requirements.txt . RUN pip install -r requirements.txt back_color="white") buffered = BytesIO() img.save(buffered
# requirements.txt Flask==2.3.0 flask-cors==4.0.0 flask-sqlalchemy==3.0.5 qrcode==7.4.2 Pillow==10.0.0 For Xibo: Use the HTML package with iframe embedding
last_hour = datetime.utcnow() - timedelta(hours=1) scans_last_hour = QRScan.query.filter(QRScan.scanned_at >= last_hour).count()