-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
40 lines (28 loc) · 869 Bytes
/
server.js
File metadata and controls
40 lines (28 loc) · 869 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
29
30
31
32
33
34
35
36
37
38
39
40
require('rootpath')();
const express = require('express');
const path = require('path');
const upload = require('controllers/upload');
const cors = require('cors');
//const port = 3000;
const port = process.env.PORT || 5000;
const app = express();
const corsOptions = {
origin: '*',
optionsSuccessStatus: 200
};
app.use(cors(corsOptions));
app.use(express.static(path.join(__dirname,'public')));
app.use('*',express.static(path.join(__dirname+'/public/index.html')));
// app.get('/', (req,res) => {
// res.send("Invalid page");
// })
app.post('/upload', upload);
//app.use('/upload', upload);
app.listen(port, () => {
console.log(`Started the server at port ${port}`);
});
// app.get('*', function(req, res, next) {
// let err = new Error('Page Not Found');
// err.statusCode = 404;
// next(err);
// });