From dc1fe02d599d6e0a86bcc6500c111455decdd6df Mon Sep 17 00:00:00 2001 From: Mahdi Dibaiee Date: Wed, 5 Apr 2017 21:07:20 +0430 Subject: [PATCH] move to /flappy-bird --- web/server.js | 13 ++++++++----- web/static/index.html | 3 --- web/static/js/main.js | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/web/server.js b/web/server.js index fee7836..1a2e399 100644 --- a/web/server.js +++ b/web/server.js @@ -4,17 +4,18 @@ var express = require('express'), io = require('socket.io')(server) exec = require('child_process').exec compression = require('compression') - path = require('path'); + path = require('path'), + router = express.Router(); server.listen(8088); -app.use(express.static(__dirname + '/static')) -app.use(compression()) -app.use('/assets/', express.static(__dirname + '/../assets/')) +router.use(express.static(__dirname + '/static')) +router.use(compression()) +router.use('/assets/', express.static(__dirname + '/../assets/')) var record = path.resolve(__dirname, '../record.py'); -app.get('/play', function(request, response) { +router.get('/play', function(request, response) { var child = exec('python3 ' + record, { maxBuffer: 1024 * 5000 }, function(err, out, stderr) { if (err || stderr) { console.log(err || stderr) @@ -26,3 +27,5 @@ app.get('/play', function(request, response) { child.stdout.pipe(response); }); + +app.use('/flappy-bird', router); diff --git a/web/static/index.html b/web/static/index.html index ba7dc49..a686b4e 100644 --- a/web/static/index.html +++ b/web/static/index.html @@ -3,9 +3,6 @@ Playing Flappy Bird using Evolution Strategies - - - diff --git a/web/static/js/main.js b/web/static/js/main.js index 98df2fd..c1fa50b 100644 --- a/web/static/js/main.js +++ b/web/static/js/main.js @@ -513,7 +513,7 @@ function newGame() { $('#loading').addClass('active'); - fetch('/play').then(res => res.json()).then(function(states) { + fetch('play').then(res => res.json()).then(function(states) { playing = true; $('#loading').removeClass('active');