-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
42 lines (33 loc) · 963 Bytes
/
server.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
const express = require('express');
const path = require("path");
const dotenv = require("dotenv");
const app = express();
const formProcess = require("./form-process");
const port = process.env.PORT || 3000;
const bodyParser = require('body-parser');
// configraration with env.
dotenv.config();
const publicDir = path.join(__dirname, "./public");
app.use(express.static(publicDir));
app.set("view engine", "ejs");
app.use(express.urlencoded({ extended: false }));
app.use(express.json());
app.use(bodyParser.json());
app.get('/', (req, res) => {
res.send('Hello World');
res.end();
});
app.get('/survey', (req, res) => {
res.render("index");
res.end();
});
app.get('/viet', (req, res) => {
res.render("viet");
res.end();
});
app.get('/allData', formProcess.getAllData);
app.get('/data', formProcess.getData);
app.post('/form-process', formProcess.submit);
app.listen(port, () => {
console.log("Connected - Port " + port);
})