forked from ionic-team/ionic-site
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
30 lines (21 loc) · 764 Bytes
/
app.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
var express = require("express"),
app = express(),
url = require('url');
process.env.PWD = process.cwd()
console.log('PWD', process.env.PWD);
app.use(function(req,res,next) {
var parts = url.parse(req.url);
if(parts.path.indexOf('/blog/') == 0) {
res.redirect(301, 'http://blog.ionic.io/' + req.url.replace(/^\/blog\//, ''));
} else if(parts.path.indexOf('/creator/') == 0) {
res.redirect(301, 'https://creator.ionic.io/' + req.url.replace(/^\/creator\//, ''))
} else {
next();
}
});
app.use(express.static(process.env.PWD + '/_site'));
// bind the app to listen for connections on a specified port
var port = process.env.PORT || 3000;
app.listen(port);
// Render some console log output
console.log("Listening on port " + port);