-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
38 lines (31 loc) · 917 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
const express = require("express");
const app = express();
const server = require("http").createServer(app);
const { Server } = require("socket.io");
const io = new Server(server);
app.use(express.urlencoded({ extended: false }));
app.use(express.json());
app.use("/assets", express.static("assets"));
app.get("/", (req, res) => {
res.sendFile(__dirname + "/subtitle.html");
});
app.get("/", (req, res) => {
res.sendFile(__dirname + "/subtitle.html");
});
app.get("/admin", (req, res) => {
res.sendFile(__dirname + "/admin.html");
});
io.on("connection", (socket) => {
console.log("连接加入");
socket.on("set", (msg) => {
console.log(msg);
io.emit("set", msg);
});
socket.on("disconnect", () => {
console.log("连接断开");
});
});
const port = 3500;
server.listen(port, () => {
console.log(`Server listening at http://localhost:${port}`);
});