Skip to content

Instantly share code, notes, and snippets.

@blangue
Created June 21, 2022 19:27
Show Gist options
  • Save blangue/d6805f5fe32dd44d5af8211989718ddb to your computer and use it in GitHub Desktop.
Save blangue/d6805f5fe32dd44d5af8211989718ddb to your computer and use it in GitHub Desktop.
var express = require('express');
var cors = require('cors');
var multer = require('multer');
const upload = multer();
require('dotenv').config()
var 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)=>{
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)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment