add 2nd endpoint to webserver; use express

This commit is contained in:
Iuri Matias 2018-02-25 19:01:50 -05:00
parent 12354e5eab
commit adc924df3e
3 changed files with 14 additions and 3 deletions

View File

@ -0,0 +1 @@
Welcome to Embark!

View File

@ -3,6 +3,8 @@ let http = require('http');
let serveStatic = require('serve-static');
const {canonicalHost, defaultHost, dockerHostSwap} = require('../../utils/host');
require('http-shutdown').extend();
var express = require('express');
let path = require('path');
class Server {
constructor(options) {
@ -20,9 +22,16 @@ class Server {
}
let serve = serveStatic(this.dist, {'index': ['index.html', 'index.htm']});
this.server = http.createServer(function onRequest(req, res) {
serve(req, res, finalhandler(req, res));
}).withShutdown();
var app = express();
app.use(serve);
app.use('/backend', serveStatic(path.join(__dirname, 'backend'), {'backend': ['index.html', 'index.htm']}));
//app.get('/embark', function (req, res) {
// res.send('Welcome to Embark')
//});
app.listen(this.port);
let message = __("webserver available at") +
" " +

View File

@ -43,6 +43,7 @@
"eth-ens-namehash": "^2.0.8",
"eth-lib": "^0.2.8",
"ethereumjs-wallet": "0.6.0",
"express": "^4.16.2",
"file-loader": "^1.1.5",
"finalhandler": "^1.1.1",
"follow-redirects": "^1.2.4",