Guess WebSocket port based on HTTP port; read dashboard.html on each request

master
Ivan Kozik 2015-07-18 04:10:15 +00:00
parent f155cbc4ed
commit 933d293305
2 changed files with 9 additions and 4 deletions

View File

@ -1453,7 +1453,12 @@ var Dashboard = function() {
JobsRenderer.prototype._renderDownloadLine = JobsRenderer.prototype._moreDomRenderDownloadLine;
}
this.host = args["host"] ? args["host"] : location.host;
if(args["host"]) {
this.host = args["host"];
} else {
// Guess that the WebSocket port is one above the HTTP port
this.host = location.hostname + ':' + (Number(location.port) + 1);
}
this.dumpTraffic = args["dumpMax"] && Number(args["dumpMax"]) > 0;
if(this.dumpTraffic) {
this.dumpMax = Number(args["dumpMax"]);

View File

@ -54,11 +54,11 @@ class MyServerFactory(WebSocketServerFactory):
self.clients = set()
dashboardHtml = open(os.path.join(os.path.dirname(__file__), "dashboard.html"), "rb").read()
@asyncio.coroutine
def dashboard(request):
return aiohttp.web.Response(body=dashboardHtml)
with open(os.path.join(os.path.dirname(__file__), "dashboard.html"), "rb") as f:
dashboardHtml = f.read()
return aiohttp.web.Response(body=dashboardHtml)
@asyncio.coroutine