-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
43 lines (33 loc) · 850 Bytes
/
app.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
const express = require("express");
const app = express();
const http = require("http").createServer(app);
const cors = require("cors");
const PORT = 8080;
app.set("view engine", 'ejs');
app.use(cors());
app.use(express.static('public'));
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
//socket and module
const adminController = require("./admin/adminController");
//game start
const Socket = require("./socket.io/socket")
Socket(http);
//routes and router
app.use("/", adminController)
app.get("/", (req, res) => {
const date = new Date();
const year = date.getFullYear();
res.render("index", {
year
})
});
app.post("/play", (req, res) => {
const { username} = req.body;
res.render("play", {
username
});
})
http.listen(PORT, () => {
console.log("Running...")
})