router.js
913 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
37
const express = require('express')
const router = express.Router()
const fs=require('fs')
const passport = require('./passport.js')
const path = require('path');
router.get('/', (req, res) => {
res.render('index', {title: "인덱스"})
})
//로그인창
router.post('/', passport.authenticate('local-login', {
successRedirect : '/loginSuccess',
failureRedirect : '/loginFail',
failureFlash : true
}))
//로그인성공
router.get('/loginSuccess', (req, res) => {
res.render('loginSuccess')
})
//로그인실패
router.get('/loginFail', (req, res) => {
res.render('loginFail')
})
//Express에서 정적파일(ex: main.html, main.js)들을 사용할경우
//경로를 미리 제시해 주는 부분
router.use(express.static(__dirname + '/main'));
//메인화면
router.get('/main', (req, res)=>{
res.sendFile(path.join(__dirname+'/main/main.html'));
})
module.exports = router