-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
42 lines (33 loc) · 959 Bytes
/
server.js
File metadata and controls
42 lines (33 loc) · 959 Bytes
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
var express = require('express');
var app = express();
var ejs = require('ejs');
var fs = require('fs');
// make static file available in public file
app.use (express.static(__dirname + '/public'));
//app.engine('html', ejs.renderFile);
//tell express to use ejs
app.use (express.bodyParser());
app.get('/', function(req, res){
res.send('hello world');
});
//http://localhost:3000/hashtag/campchamp/btv
app.get('/hashtag/:hashtag1/:hashtag2',function(req,res){
var responsemessage = req.params.hashtag1;
res.send('hello' + responseMessage);
});
app.get('/fib/:index', function9req. res){
var index = parsInt(req.params.index);
if(typeof index !== 'number'){
console.log("typeof index !== 'number'");
} else{
console.log("typeof index === 'number'");
}
var fib = [0,1];
for( i = 0; i <= req.params.index; i++){
//do stuff
fib[i+2] = fib [i] + fib[i+1];
}
//echo it out
res.send(fib[req.params.index] + '');
});
app.listen(3000);