equal
deleted
inserted
replaced
|
1 var express = require('express'); |
|
2 var cookie = require('cookie-parser') |
|
3 var crypto = require('crypto'); |
|
4 |
|
5 var app = express(); |
|
6 app.use(cookie()); |
|
7 |
|
8 app.get('/', function(req, res){ |
|
9 var counter = req.cookies.counter || 0; |
|
10 res.cookie('counter', counter + 1); |
|
11 if (counter >= 5) { |
|
12 res.write('You are a valued customer ' + |
|
13 'visting the site ' + counter + ' times.'); |
|
14 } else { |
|
15 res.write('This is visit number '+ counter +'!'); |
|
16 } |
|
17 res.end(); |
|
18 }); |
|
19 |
|
20 // starting the server |
|
21 app.listen(8000); |
|
22 console.log("Server running at http://127.0.0.1:8000/"); |