38 lines
751 B
JavaScript
Executable File
38 lines
751 B
JavaScript
Executable File
import express from 'express';
|
|
import bodyParser from 'body-parser';
|
|
import fs from 'fs';
|
|
import path from 'path';
|
|
|
|
import fileUpload from 'express-fileupload';
|
|
|
|
import { pdf } from "pdf-to-img";
|
|
|
|
const app = express();
|
|
|
|
app.use(bodyParser.json());
|
|
|
|
app.use(fileUpload());
|
|
|
|
app.post('/convert', async(req, res) => {
|
|
|
|
console.log(req.files);
|
|
|
|
let file = req.files.pdf;
|
|
|
|
let images = [];
|
|
const document = await pdf(file.data, { scale: 3 });
|
|
|
|
for await (const image of document) {
|
|
images.push(image);
|
|
}
|
|
|
|
res.send(images);
|
|
});
|
|
|
|
app.get('/', (req, res) => {
|
|
res.send('Hello World');
|
|
});
|
|
|
|
app.listen(5000, () => {
|
|
console.log('Server is running on http://localhost:3000');
|
|
}); |