seungmi

조건을 입력할 때 추천 음식이 출력되는 '/food' page수정

'http://localhost:3000/food/recommendation' page에서 조건을 입력하였을 때,
'http://localhost:3000/food' page에서 추천 음식이 출력되도록 post방식의 함수 수정
Showing 1 changed file with 10 additions and 5 deletions
......@@ -24,7 +24,7 @@ app.get(['/food', '/food/:id'], function(req, res) {
} else if (id == 'recommendation') {
res.render('recommendation.ejs', {
title: 'Recommendation',
description: 'We recommend this...'
description: 'Enter the conditions you want.'
});
}
} else {
......@@ -36,16 +36,21 @@ app.get(['/food', '/food/:id'], function(req, res) {
})
app.post('/food', function(req, res) {
var price = req.body.price;
var shape = req.body.shape;
var kinds = req.body.kinds;
fs.readFile('data/food.json', 'utf8', function(err, data) {
if (err) {
console.log((err));
res.status(500).send('Internal Server Error');
} else {
var users = JSON.parse(data);
res.json(users);
var price = req.body.price;
var shape = req.body.shape;
var kinds = req.body.kinds;
res.render('print.ejs',{
title: 'Recommendation',
description: 'We recommend this...',
name: users[1]["name"]
});
}
})
})
......