Spaces:
Running
Running
Update server.js
Browse files
server.js
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
'use strict';
|
2 |
|
3 |
const express = require('express');
|
|
|
4 |
|
5 |
// Constants
|
6 |
const PORT = 7860;
|
@@ -11,6 +12,19 @@ const app = express();
|
|
11 |
app.get('/', (req, res) => {
|
12 |
res.send('Hello World from ExpressJS! This example is from the NodeJS Docs: https://nodejs.org/en/docs/guides/nodejs-docker-webapp/');
|
13 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
app.listen(PORT, HOST, () => {
|
16 |
console.log(`Running on http://${HOST}:${PORT}`);
|
|
|
1 |
'use strict';
|
2 |
|
3 |
const express = require('express');
|
4 |
+
import Lens from 'chrome-lens-ocr';
|
5 |
|
6 |
// Constants
|
7 |
const PORT = 7860;
|
|
|
12 |
app.get('/', (req, res) => {
|
13 |
res.send('Hello World from ExpressJS! This example is from the NodeJS Docs: https://nodejs.org/en/docs/guides/nodejs-docker-webapp/');
|
14 |
});
|
15 |
+
const lens = new Lens();
|
16 |
+
|
17 |
+
app.get('/scanByUrl', async (req, res) => {
|
18 |
+
const { url } = req.query;
|
19 |
+
try {
|
20 |
+
const data = await lens.scanByURL(url);
|
21 |
+
const combinedText = data.segments.map(segment => segment.text).join(' ');
|
22 |
+
res.json({ combinedText, detailedData: data });
|
23 |
+
} catch (error) {
|
24 |
+
res.status(500).json({ error: error.message });
|
25 |
+
}
|
26 |
+
});
|
27 |
+
|
28 |
|
29 |
app.listen(PORT, HOST, () => {
|
30 |
console.log(`Running on http://${HOST}:${PORT}`);
|