Initial Code Commit
This commit is contained in:
38
File Converter/index.js
Executable file
38
File Converter/index.js
Executable file
@@ -0,0 +1,38 @@
|
||||
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');
|
||||
});
|
||||
Reference in New Issue
Block a user