Closed rocketinventor closed 7 years ago
Hi, the problem is that the html and javascript are served as local file:// URLs. So you can't access them over the network. We should serve them through the web server to fix this.
To do this, we need to configure the flask static_folder
to point to a path containing demoBot.html
jgboard-latest.js
and board.js
. Then update the postMove
URL to be relative instead of absolute.
PS. @rocketinventor, if you are interested in contributing to betago this would be a really useful and straightforward place to start :)
I'm still working on getting flask to serve the files statically. My current efforts are not working though. It looks something like this and is based in part on this guide b/c I didn't understand this one. Workspace url: https://ide.c9.io/rocketinventor/beta-go
The postMove
URL part is done, though, I'll push it out when I get the flask server running.
P.s. @macfergus Thanks for helping me get started 👍
Your diff looks good, I think the only thing you're missing is to change
app = Flask(__name__)
to
app = Flask(__name__, static_folder='../ui')
or something like that. All the calls to send_static_file
and such are relative to static_folder
.
Thanks for tackling this!
After several moths of inactivity, I finally noticed that the C9 IDE documentation says explicitly that you can only use ports 8080 - 8082
.
I'm going to take another look to see if that was my problem.
Great to hear! Let me know if it solved your problem. Haven't had time to work on betago for a very long time either...
@maxpumperla No luck so far. I don't think this is a c9 issue, right now because I can't get it to work in curl, either. I tried running betago according to the instructions, then I tried running the following in bash:
rocketinventor:~/workspace/betago (master) $ curl 0.0.0.0:8081/prediction
curl: (7) Failed to connect to 0.0.0.0 port 8081: Connection refused
rocketinventor:~/workspace/betago (master) $ curl 0.0.0.0:5000/prediction
curl: (7) Failed to connect to 0.0.0.0 port 5000: Connection refused
rocketinventor:~/workspace/betago (master) $ curl localhost:5000/prediction
curl: (7) Failed to connect to localhost port 5000: Connection refused
Here is the traceback from flask (change the ext to .html)
Traceback (most recent call last):
File "/home/ubuntu/workspace/.betago/lib/python2.7/site-packages/flask/app.py", line 1836, in __call__
return self.wsgi_app(environ, start_response)
File "/home/ubuntu/workspace/.betago/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/home/ubuntu/workspace/.betago/lib/python2.7/site-packages/flask_cors/extension.py", line 188, in wrapped_function
return cors_after_request(app.make_response(f(*args, **kwargs)))
File "/home/ubuntu/workspace/.betago/lib/python2.7/site-packages/flask/app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/ubuntu/workspace/.betago/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "/home/ubuntu/workspace/.betago/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/ubuntu/workspace/.betago/lib/python2.7/site-packages/flask_cors/extension.py", line 188, in wrapped_function
return cors_after_request(app.make_response(f(*args, **kwargs)))
File "/home/ubuntu/workspace/.betago/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/ubuntu/workspace/.betago/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "/home/ubuntu/workspace/.betago/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/ubuntu/workspace/betago/betago/model.py", line 49, in next_move
row = content['i']
TypeError: 'NoneType' object has no attribute '__getitem__'
@maxpumperla Everything works now! Please merge #28 so that others can benefit as well.
Hi, I was able to get the python code for c9 working but it auto-opens in lynx and I cannot figure out how to play the demo. Any tips?