forked from weidazhao/service-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
27 lines (21 loc) · 987 Bytes
/
server.js
File metadata and controls
27 lines (21 loc) · 987 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
var os = require('os');
var request = require('request');
var morgan = require('morgan');
var express = require('express');
var app = express();
app.use(express.static(__dirname + '/public')); // set the static files location /public/img will be /img for users
app.use(require("morgan")("dev"));
// api ---------------------------------------------------------------------
app.get('/api', function (req, res) {
request('http://dazhao-swarm2agents.westus.cloudapp.azure.com/api/hello', function (error, response, body) {
res.send('Hello from service-dotnet: ' + body);
});
});
// application -------------------------------------------------------------
app.get('/', function (req, res) {
res.sendFile(__dirname + '/public/index.html'); // load the single view file (angular will handle the page changes on the front-end)
});
var port = process.env.PORT || 3000;
app.listen(port, function () {
console.log("Listening on port " + port);
});