Skip to content

Commit

Permalink
cookie3 : 쇼핑몰 장바구니 기능1 예제
Browse files Browse the repository at this point in the history
  • Loading branch information
egoing committed Mar 25, 2016
1 parent 803c363 commit 656a290
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions app_cookie.js
Expand Up @@ -2,6 +2,21 @@ var express = require('express');
var cookieParser = require('cookie-parser');
var app = express();
app.use(cookieParser());
var products = {
1:{title:'The history of web 1'},
2:{title:'The next web'}
};
app.get('/products', function(req, res){
var output = '';
for(var name in products) {
output += `
<li>
<a href="/cart/${name}">${products[name].title}</a>
</li>`
}
res.send(`<h1>Products</h1><ul>${output}</ul><a href="/cart">Cart</a>`);
});

app.get('/count', function(req, res){
if(req.cookies.count){
var count = parseInt(req.cookies.count);
Expand Down

0 comments on commit 656a290

Please sign in to comment.