-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
30 lines (25 loc) · 830 Bytes
/
Copy pathapp.js
File metadata and controls
30 lines (25 loc) · 830 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
var express = require('express');
var app = express();
var path = require('path');
function isMobileDevice(ua) {
var judge = /(iphone|ios|android|mini|mobile|mobi|Nokia|Symbian|iPod|iPad|Windows\s+Phone|MQQBrowser|wp7|wp8|UCBrowser7|UCWEB|360\s+Aphone\s+Browser)/i.test(ua);
if (judge) {
return true;
}
return false;
};
app.set('views', __dirname + '/view');
app.use(express.static(path.join(__dirname,'lib')));
app.use(express.static(path.join(__dirname,'node_modules')));
app.use(express.static(path.join(__dirname,'src')));
app.get('*',(req, res) => {
var userAgent = req.headers['user-agent'];
if (isMobileDevice(userAgent)) {
res.sendFile(__dirname + '/view/m.index.html');
}
else {
res.sendFile(__dirname + '/view/index.html');
}
});
app.listen(4001);
console.log('running on port:4001');