-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
26 lines (22 loc) · 782 Bytes
/
Copy pathserver.js
File metadata and controls
26 lines (22 loc) · 782 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
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
//const cors = require('cors');
const path = require('path');
let port = process.env.PORT;
if (port == null || port == "") {
port = 5001;
}
app.listen(port);
app.use(bodyParser.urlencoded({
extended: true
}));
app.use ( bodyParser.json( { type: "*/*" } ));
app.use(express.static(__dirname + '/'));
app.get('/', async (req, res) => {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
res.header('Access-Control-Allow-Methods: GET, POST, PATCH, PUT, DELETE, OPTIONS');
res.sendFile(path.join(__dirname + 'index.html'));
});
console.log(__dirname + '\index.html');