Initialize the UI code
[holmes/rule-management.git] / rulemgt / src / main / frontend / src / public / framework / appserver / server.js
1 /*
2
3     Copyright 2016-2017, Huawei Technologies Co., Ltd.
4
5     Licensed under the Apache License, Version 2.0 (the "License");
6     you may not use this file except in compliance with the License.
7     You may obtain a copy of the License at
8
9             http://www.apache.org/licenses/LICENSE-2.0
10
11     Unless required by applicable law or agreed to in writing, software
12     distributed under the License is distributed on an "AS IS" BASIS,
13     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14     See the License for the specific language governing permissions and
15     limitations under the License.
16
17 */
18
19 // Dependencies
20 var express = require('express');
21 var bodyParser = require('body-parser');
22 var http=require("http");
23 var path=require('path');
24
25
26 // Express
27 var app = express();
28 app.use(bodyParser.urlencoded({ extended: true}));
29 app.use(bodyParser.json());
30 app.use(function(req, res, next) {
31     res.header("Access-Control-Allow-Origin", "*");
32     res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
33     next();
34 });
35 app.use(express.static(__dirname + '/POC_Angular'));
36
37 // Routes
38 app.use('/api', require('./api'));
39
40 // viewed at http://localhost:3000
41 app.get('/', function(req, res) {
42         res.sendFile(path.join(__dirname + '/POC_Angular/index.html'));
43 });
44
45 // Start server
46 app.listen(3000);
47 console.log('API is running on port 3000');
48 console.log('API @@@@');