'use strict'; const express = require('express'); import Lens from 'chrome-lens-ocr'; // Constants const PORT = 7860; const HOST = '0.0.0.0'; // App const app = express(); app.get('/', (req, res) => { res.send('Hello World from ExpressJS! This example is from the NodeJS Docs: https://nodejs.org/en/docs/guides/nodejs-docker-webapp/'); }); const lens = new Lens(); app.get('/scanByUrl', async (req, res) => { const { url } = req.query; try { const data = await lens.scanByURL(url); const combinedText = data.segments.map(segment => segment.text).join(' '); res.json({ combinedText, detailedData: data }); } catch (error) { res.status(500).json({ error: error.message }); } }); app.listen(PORT, HOST, () => { console.log(`Running on http://${HOST}:${PORT}`); });