-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhola.js
52 lines (40 loc) · 1.29 KB
/
hola.js
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
const port = process.env.PORT || 5000;
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.get('/api/hello', (req, res) => {
res.send({ express: 'Hello From Express' });
});
app.get('/', function(req, res){
res.sendFile('index.html');
});
app.get('/api/getFile', function(req, res){
res.sendFile(basepath + '/gabythom/c8jyd9belZNi:NfhxBG5qllHXi+oTv0T4g+xFbSx');
});
app.post('/api/world', (req, res) => {
console.log(req.body);
res.send(
`I received your POST request. This is what you sent me: ${req.body.post}`,
);
});
const multer = require("multer");
var basepath = process.cwd();
const multerConfig = {
storage: multer.diskStorage({
//Setup where the user's file will go
destination: function(req, files, next){
next(null,basepath + '/gabythom');
},
//Then give the file a unique name
filename: function(req, files, next){
//console.log(files);
next(null, files.originalname);
}
})
}
app.post('/api/file',multer(multerConfig).array('files',2),function(req,res){
res.send('Complete!');
});
app.listen(port, () => console.log(`Listening on port ${port}`));