import fs from 'fs'; import path from 'path'; import axios from 'axios'; async function downloadQR(url: string, outputPath: string) { const qrApiUrl = `https://api.qrserver.com/v1/create-qr-code/?size=300x300&data=${encodeURIComponent(url)}`; const response = await axios({ url: qrApiUrl, method: 'GET', responseType: 'stream', }); return new Promise((resolve, reject) => { const writer = fs.createWriteStream(outputPath); response.data.pipe(writer); writer.on('finish', () => resolve()); writer.on('error', (err) => reject(err)); }); } async function main() { const localUrl = 'http://localhost:3000/ipv6/feedback'; const prodUrl = 'https://techvanguard.vn/ipv6/feedback'; const publicDir = path.join(__dirname, '../public/assets/img'); if (!fs.existsSync(publicDir)) { fs.mkdirSync(publicDir, { recursive: true }); } const localPath = path.join(publicDir, 'feedback-qr-local.png'); const prodPath = path.join(publicDir, 'feedback-qr-prod.png'); console.log('Downloading QR code for local URL:', localUrl); await downloadQR(localUrl, localPath); console.log('Saved local QR to:', localPath); console.log('Downloading QR code for prod URL:', prodUrl); await downloadQR(prodUrl, prodPath); console.log('Saved prod QR to:', prodPath); // Copy to artifact directory const artifactDir = 'C:\\Users\\Admin\\.gemini\\antigravity-ide\\brain\\c96f6734-1739-4dd2-b415-68dac04243f7'; if (fs.existsSync(artifactDir)) { fs.copyFileSync(localPath, path.join(artifactDir, 'feedback-qr-local.png')); fs.copyFileSync(prodPath, path.join(artifactDir, 'feedback-qr-prod.png')); console.log('Copied QR codes to artifact directory.'); } } main().catch(console.error);