29 lines
702 B
JavaScript
29 lines
702 B
JavaScript
const express = require('express');
|
|
const cors = require('cors');
|
|
const multer = require('multer')
|
|
const upload = multer({ dest: 'uploads/' })
|
|
require('dotenv').config()
|
|
|
|
const app = express();
|
|
|
|
app.use(cors());
|
|
app.use('/public', express.static(process.cwd() + '/public'));
|
|
|
|
app.get('/', function (req, res) {
|
|
res.sendFile(process.cwd() + '/views/index.html');
|
|
});
|
|
|
|
app.post('/api/fileanalyse', upload.single('upfile'), (req, res) => {
|
|
console.log(req.file)
|
|
res.json({
|
|
name: req.file.originalname,
|
|
type: req.file.mimetype,
|
|
size: req.file.size
|
|
})
|
|
})
|
|
|
|
|
|
const port = process.env.PORT || 3000;
|
|
app.listen(port, function () {
|
|
console.log('Your app is listening on port ' + port)
|
|
});
|