server.js
1.24 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
41
42
43
44
45
46
47
48
const express = require("express");
const fs = require("fs");
const cors = require("cors");
const loginRouter = require("./routers/Login");
const dbRouter = require("./routers/DB");
const path = require("path");
const app = express();
app.use(
cors({
origin: "http://3.34.173.161:3000",
credentials: true,
})
);
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use("/login", loginRouter);
app.use("/db", dbRouter);
// fs.readFile("server/libs/login.pvdata", "utf8", async (err, data) => {
// if (err) {
// console.error(err);
// console.log("server/libs/login.pvdata에 ID\\nPW를 작성");
// return;
// }
// const page = await login(...data.split("\r\n"));
// if (page) {
// const feed = await getPeed(page);
// const subjects = await getSubjects(page);
// console.log({ feed, subjects });
// app.listen(3001, function () {
// console.log("listening on 3001");
// });
// } else console.log("Incorrect user ID or password.");
// });
app.use(express.static(path.join(__dirname, "../build")));
app.get("*", function (요청, 응답) {
응답.sendFile(path.join(__dirname, "../build/index.html"));
});
app.listen(3001, function () {
console.log("listening on 3001");
});