-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver-srv.js
59 lines (48 loc) · 1.87 KB
/
server-srv.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
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
var url = require('url');
var express = require('express');
const cors = require('cors');
var compression = require('compression');
var path = require('path');
var port = process.env.PORT || 1881;
var app = express();
// viewed at http://localhost:1881
app.use(compression());
app.disable('x-powered-by');
app.get('/robots.txt', function (req, res) {
res.type('text/plain');
res.send("User-agent: *\nDisallow: \nSitemap: http://"+req.headers.host+"/sitemap.xml");
});
app.get('/manifest.json', function (req, res) {
filePath = '/public/manifest.json';
res.sendFile(path.join(__dirname + filePath));
});
app.get('/googlea9ce7ea88d34d673.html', function (req, res) {
filePath = '/public/googlea9ce7ea88d34d673-fr.html';
if ((req.headers.host == 'www.wespeakhiphop.com') || (req.headers.host == 'wespeakhiphop.com'))
filePath = '/public/googlea9ce7ea88d34d673.html';
res.sendFile(path.join(__dirname + filePath));
});
app.get('/browserconfig.xml', function (req, res) {
filePath = '/public/browserconfig.xml';
res.sendFile(path.join(__dirname + filePath));
});
app.get('/sw.js', function (req, res) {
filePath = '/public/sw.js';
res.sendFile(path.join(__dirname + filePath));
});
app.get('/sitemap.xml', function (req, res) {
filePath = '/public/sitemap.xml';
if ((req.headers.host == 'www.wespeakhiphop.com') || (req.headers.host == 'wespeakhiphop.com'))
filePath = '/public/sitemap-en.xml';
res.sendFile(path.join(__dirname + filePath));
});
app.get('/', function(req, res) {
var filePath = '.' + req.url;
if (filePath == './')
if ((req.headers.host == 'www.wespeakhiphop.com') || (req.headers.host == 'wespeakhiphop.com'))
filePath = '/public/index_en.html';
else
filePath = '/public/index.html';
res.sendFile(path.join(__dirname + filePath));
});
app.listen(port);