윤희찬

Update router.js, main.html and main.js

1 -<style type='text/css'>
2 - @import url("style.css");
3 - </style>
4 1
5 <!DOCTYPE html> 2 <!DOCTYPE html>
6 <html lang="en"> 3 <html lang="en">
...@@ -30,4 +27,4 @@ ...@@ -30,4 +27,4 @@
30 </section> 27 </section>
31 <script src="./main.js"></script> 28 <script src="./main.js"></script>
32 </body> 29 </body>
33 - </html>
...\ No newline at end of file ...\ No newline at end of file
30 + </html>
......
...@@ -14,7 +14,7 @@ searchForm.addEventListener('submit', function(event){ ...@@ -14,7 +14,7 @@ searchForm.addEventListener('submit', function(event){
14 }); 14 });
15 15
16 async function fetchAPI(){ 16 async function fetchAPI(){
17 - const recipeURL = `https://api.edamam.com/search?q=${searchQuery}&app_id=${APP_ID}&app_key=${APP_KEY}`; 17 + const recipeURL = `https://api.edamam.com/search?q=pizza&app_id=${APP_ID}&app_key=${APP_KEY}`;
18 const response = await fetch(recipeURL); 18 const response = await fetch(recipeURL);
19 const data = await response.json(); 19 const data = await response.json();
20 boxinfo(data.hits); 20 boxinfo(data.hits);
...@@ -37,4 +37,4 @@ function boxinfo(results){ ...@@ -37,4 +37,4 @@ function boxinfo(results){
37 ` 37 `
38 }) 38 })
39 searchResultDiv.innerHTML = boxsinfo; 39 searchResultDiv.innerHTML = boxsinfo;
40 -}
...\ No newline at end of file ...\ No newline at end of file
40 +}
......
...@@ -3,18 +3,18 @@ const router = express.Router() ...@@ -3,18 +3,18 @@ const router = express.Router()
3 const fs=require('fs') 3 const fs=require('fs')
4 const passport = require('./passport.js') 4 const passport = require('./passport.js')
5 const path = require('path'); 5 const path = require('path');
6 - 6 +
7 router.get('/', (req, res) => { 7 router.get('/', (req, res) => {
8 res.render('index', {title: "인덱스"}) 8 res.render('index', {title: "인덱스"})
9 }) 9 })
10 - 10 +
11 //로그인창 11 //로그인창
12 router.post('/', passport.authenticate('local-login', { 12 router.post('/', passport.authenticate('local-login', {
13 - successRedirect : '/loginSuccess', 13 + successRedirect : '/loginSuccess',
14 - failureRedirect : '/loginFail', 14 + failureRedirect : '/loginFail',
15 - failureFlash : true 15 + failureFlash : true
16 })) 16 }))
17 - 17 +
18 //로그인성공 18 //로그인성공
19 router.get('/loginSuccess', (req, res) => { 19 router.get('/loginSuccess', (req, res) => {
20 res.render('loginSuccess') 20 res.render('loginSuccess')
...@@ -25,9 +25,13 @@ router.get('/loginFail', (req, res) => { ...@@ -25,9 +25,13 @@ router.get('/loginFail', (req, res) => {
25 res.render('loginFail') 25 res.render('loginFail')
26 }) 26 })
27 27
28 +//Express에서 정적파일(ex: main.html, main.js)들을 사용할경우
29 +//경로를 미리 제시해 주는 부분
30 +router.use(express.static(__dirname + '/main'));
31 +
28 //메인화면 32 //메인화면
29 router.get('/main', (req, res)=>{ 33 router.get('/main', (req, res)=>{
30 res.sendFile(path.join(__dirname+'/main/main.html')); 34 res.sendFile(path.join(__dirname+'/main/main.html'));
31 }) 35 })
32 36
33 -module.exports = router
...\ No newline at end of file ...\ No newline at end of file
37 +module.exports = router
......