Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
Latest commit
58 lines (46 loc) · 1.39 KB
/
Copy pathserver.js
File metadata and controls
58 lines (46 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
varexpress=require('express');
varpath=require('path');
varfavicon=require('serve-favicon');
varlogger=require('morgan');
varcookieParser=require('cookie-parser');
varbodyParser=require('body-parser');
varemojiFavicon=require('emoji-favicon');
varapp=express();
varport=process.env.PORT||12003;
// uncomment after placing your favicon in /public
//app.use(favicon(__dirname + '/public/favicon.ico'));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: false}));
app.use(cookieParser());
app.use(express.static(path.join(__dirname,'public')));
app.use('/bower',express.static(path.join(__dirname,'bower_components')));
app.use('/up',require('./routes/up'));
app.get('/r',function(req,res){
varfiveSeconds=Math.floor(newDate().getTime()/5000);
if(req.query.r!=fiveSeconds){
res.redirect('?r='+fiveSeconds);
}else{
res.send('Safe');
}
});
app.use(emojiFavicon('smiley'));
// catch 404 and forward to error handler
app.use(function(req,res,next){
varerr=newError('Not Found');
err.status=404;
next(err);
});
// error handlers
// development error handler
// will print stacktrace
app.use(function(err,req,res,next){
res.status(err.status||500);
res.send({
message: err.message,
error: err
});
});
app.listen(port)
console.log("Listening on port "+port)
module.exports=app;