-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
28 lines (22 loc) · 862 Bytes
/
Copy pathserver.js
File metadata and controls
28 lines (22 loc) · 862 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const express = require('express')
const path = require('path')
const app = express()
const multer = require('multer')
const {mergePdfs} = require('./merge')
const upload = multer({ dest: 'uploads/' })
app.use('/static', express.static('public'))
const port = 3000
app.get('/', (req, res) => {
res.sendFile(path.join(__dirname, "templates/index.html"))
})
app.post('/merge', upload.array('pdfs', 2), async (req, res, next)=> {
// console.log(req.files)
let d = await mergePdfs(path.join(__dirname, req.files[0].path), path.join(__dirname, req.files[1].path))
res.redirect(`http://localhost:3000/static/${d}.pdf` )
// res.send({data: req.files})
// req.files is array of `photos` files
// req.body will contain the text fields, if there were any
})
app.listen(port, () => {
console.log(`App listening on port http://localhost:${port}`)
})