This repository has been archived by the owner on Aug 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
64 lines (50 loc) · 1.63 KB
/
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
const express = require('express')
const bodyParser = require('body-parser')
const ejs = require('ejs')
const app = express()
const port = 3001
app.use(bodyParser.urlencoded({ extended: false }))
app.set('view engine', 'ejs')
app.set ('views', './views')
app.get('/', function(req, res) {
res.render('index')
})
app.get('/login', function(req, res) {
res.render('login')
})
app.get('/counseling', function(req, res) {
res.render('counseling')
})
app.get('/agecareer', function(req, res) {
res.render('agecareer')
})
app.get('/signup', function(req, res) {
res.render('signup')
})
app.get('/mypage', function(req, res) {
res.render('mypage')
})
app.post('/signupform', function(req, res) {
const username = req.body.username
const password = req.body.password
const passwordconfirm = req.body.passwordConfirm
if (password == passwordconfirm)
console.log(`Sign Up Success => ID: ${username}, PASSWORD: ${password}`)
else
console.log(`Sign Up Failed => Confirm Password Incorrect.`)
})
app.post('/submitlogin', function(req, res) {
const username = req.body.username
const password = req.body.password
console.log(`Login Request | ID: ${username}, PASSWORD: ${password}`)
})
app.use(function(req, res) { // Page Not Found
res.status(404).render('error', { errorCode: 404 });
});
app.use(function(err, req, res, next) { // Internal Server Error
console.error(err.stack);
res.status(500).render('error', { errorCode: 500 });
});
app.listen(port, () => {
console.log(`Hosting at port ${port}`)
})