-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
36 lines (29 loc) · 930 Bytes
/
app.js
File metadata and controls
36 lines (29 loc) · 930 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
27
28
29
30
31
32
33
34
35
36
const express = require("express");
const app = express();
const hostname = "localhost";
const nunjucks = require("nunjucks");
const path = require("path");
const uploadRouter = require("./routes/uploadRouter.js");
const chartRouter = require("./routes/chartRouter.js");
const bodyParser = require("body-parser");
// 넌적스 세팅
app.set("port", 3000);
app.set("view engine", "html");
app.use("/", express.static(__dirname + "/views"));
nunjucks.configure("views", {
autoescape: true,
express: app,
watch: true,
});
//router 세팅
app.use("/", uploadRouter);
app.use("/chart", chartRouter);
// '/'와 '/chart' 말고 다른곳 진입했을경우 실행
app.use((req, res, next) => {
res.status(404).send("Not Found");
});
app.listen(app.get("port"), () => {
console.log(`서버 링크 : http://${hostname}:${app.get("port")}/`);
});
//한글 깨짐 현상
app.use(bodyParser.urlencoded({ extended: true }));