Repository navigation
Expand file tree
/
Copy pathserver.js
More file actions
60 lines (52 loc) · 1.39 KB
/
Copy pathserver.js
File metadata and controls
60 lines (52 loc) · 1.39 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
var express = require('express');
var bodyParser = require('body-parser');
var _ = require('underscore');
var app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.static('public'));
app.use(require('connect-livereload')());
app.get('/', function (request, response) {
response.sendfile('public/index.html');
});
app.get('/api/sample', function(request, response){
response.send({name:"Ravi"});
});
app.get('/api/achievements/:type', function(request, response) {
var achievements=[
{
title:'Received Microsoft MVP Award',
type:'major'
},
{
title:'Approved as SitePoint author',
type:'major'
},
{
title:'Approved as DotnetCurry author',
type:'major'
},
{
title:'Mention on ASP.NET',
type:'medium'
},
{
title:'First article published on SitePoint',
type:'minor'
},
{
title:'Got a side project',
type:'minor'
},
{
title:'Boss patted me for my work',
type:'minor'
}
];
response.send(_.filter(achievements, function(a){
return a.type === request.params.type;
}));
});
app.listen(8000, function () {
console.log('Express server started!!!');
});