res.json( code ); );
fetchNewCode(); </script> </body> </html> <!-- public/activate.html --> <!DOCTYPE html> <html> <head> <title>Viaplay – Activate Device</title> <style> body font-family: system-ui, -apple-system, sans-serif; background: #f0f2f5; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; .card background: white; padding: 2rem; border-radius: 32px; box-shadow: 0 20px 35px rgba(0,0,0,0.1); width: 350px; text-align: center; h1 color: #00a6a6; input width: 100%; padding: 15px; font-size: 1.5rem; text-align: center; letter-spacing: 5px; font-family: monospace; border: 2px solid #ddd; border-radius: 60px; margin: 20px 0; button background: #00a6a6; color: white; border: none; padding: 12px 24px; font-size: 1.2rem; border-radius: 40px; width: 100%; cursor: pointer; font-weight: bold; button:hover background: #008080; .error color: red; margin-top: 15px; .success color: green; margin-top: 15px; .note margin-top: 20px; font-size: 0.8rem; color: #555; </style> </head> <body> <div class="card"> <h1>🎬 Viaplay Activation</h1> <p>Enter the code shown on your TV</p> <input type="text" id="codeInput" maxlength="6" placeholder="000000" autofocus> <button id="activateBtn">Activate Device</button> <div id="message"></div> <div class="note">Code expires in 10 minutes</div> </div> <script> const activateBtn = document.getElementById('activateBtn'); const codeInput = document.getElementById('codeInput'); const messageDiv = document.getElementById('message'); activate viaplay
// Generate a new 6-digit activation code function generateCode() return Math.floor(100000 + Math.random() * 900000).toString(); res.json( code )
catch (err) messageDiv.innerHTML = '❌ Network error. Try again.'; messageDiv.className = 'error'; !-- public/activate.html -->
// API: TV requests a new activation code app.post('/api/request-code', (req, res) => const code = generateCode(); codes.set(code, status: 'pending', deviceId: null, createdAt: Date.now() );