dev_server.js
901 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
31
32
33
34
35
36
37
38
39
40
41
'use strict';
var path = require('path');
var express = require('express');
var app = express();
var conf = {
paths: {
root: '../../../../../'
},
port: '8182'
}
if (process.env.ONOS_EXTERNAL_APP_DIRS) {
var external_apps = process.env.ONOS_EXTERNAL_APP_DIRS.replace(/\s/,'').split(',');
external_apps.forEach(function(a, i){
let [appName, appPath] = a.split(':');
conf.paths[appName] = appPath;
});
}
var httpProxyInit = function (baseDirs) {
Object.keys(baseDirs).forEach(dir => {
var d = path.isAbsolute(baseDirs[dir]) ? baseDirs[dir] : path.join(__dirname, baseDirs[dir]);
app.use(express.static(d));
});
app.get('/', function (req, res) {
res.send('Hello World!');
});
app.listen(conf.port, function () {
console.log(`Dev server is up and listening on http://localhost:${conf.port}!`);
});
};
httpProxyInit(conf.paths);