김태민

이미지 출력 추가

......@@ -4,6 +4,7 @@ var bodyParser = require('body-parser');
var fs = require("fs");
app.use(express.static('public'));
app.use('/images', express.static(__dirname + '/images'));
app.use(bodyParser.json());
app.use(bodyParser.text());
app.use(bodyParser.urlencoded({
......@@ -106,11 +107,15 @@ app.post('/food/recommendation', function(req, res) {
console.log('food 갯수: '+length);
var rand = Math.floor(Math.random() * length); //(Math.random() * (max - min)) + min
var food_value = food[rand];
var food_picture = '/images/' + food_value + ".png";
console.log('랜덤 food 번호: '+rand);
res.render('print.ejs', {
title: 'Recommendation',
description: 'We recommend this...',
randvalue: food_value
randvalue: food_value,
picture : food_picture
}); //rander closed
}); //add closed
}
......
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
......@@ -22,8 +23,8 @@
</h2>
<p><%= description %></p>
<p><%= randvalue%></p>
<img src = <%= picture%>>
</article>
</div class="grid">
</body>
</html>
......