-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
41 lines (27 loc) · 1.09 KB
/
index.js
File metadata and controls
41 lines (27 loc) · 1.09 KB
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
const express = require("express");
const path = require("path");
const http = require("http");
const session = require("express-session");
const bodyParser = require("body-parser");
const app = express();
const server = http.createServer(app);
app.use(session({ secret: "ssshhhhh", saveUninitialized: true, resave: true }));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.static(__dirname + "/src"));
app.set("port", process.env.port || 8080);
app.set("views", path.join(__dirname, "src"));
app.use("/assets", express.static(path.join(__dirname, "assets")));
app.use(function (req, res, next) {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type');
res.setHeader('Access-Control-Allow-Credentials', 1);
next();
});
app.get("/",(req,res) => {
res.sendFile("index.html")
})
server.listen(app.get("port"), () => {
console.log("App listening to port %d", app.get("port"));
});