-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
28 lines (25 loc) · 853 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
/*eslint new-cap:0 */
'use strict';
var path = require('path');
var express = require('express');
var useragent = require('express-useragent');
var app = express();
var http = require('http').Server(app);
var options = {
port: process.env.VCAP_APP_PORT || 3000
};
app.use(useragent.express());
app.use(express.static(path.join(__dirname, '/public')));
app.get('/', function(req, res) {
if(req.useragent.isiPad || req.useragent.isiPod || req.useragent.isiPhone) {
console.log('You sir, are a Apple lover!');
} else if (req.useragent.isAndroid) {
console.log('Hi there, still using Android?');
} else if (req.useragent.isLinux) {
console.log('I cant help you');
} else if (req.useragent.isDesktop) {
console.log('You are on a desktop');
}
res.send(req.useragent);
});
http.listen(options.port);