-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
40 lines (32 loc) · 870 Bytes
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
var express = require('express');
var ejs = require('ejs');
var fs = require('fs');
var app = express();
var templateString = null;
var count = 0;
fs.readFile('template.ejs', function(err, data) {
if(!err) {
templateString = data;
}
});
// configure Express
app.configure(function() {
app.use(app.router);
app.use(express.static(__dirname + '/'));
});
app.get('/', function(req, res){
res.redirect('/app/index.html')
})
app.get('/template', function(req, res){
res.end("This data has been returned from the server. This proves that AJAX is working.")
})
app.get('/count', function(req, res){
count ++;
res.send("This has been seen " + count + " times. AJAX lazy loading is working.");
})
app.use(function(req, res, next){
console.log('%s %s', req.method, req.url);
next();
});
console.log("listening on port 3000")
app.listen(3000);