Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[webservice] Slight adjustment to how we respond, and can reply with …

…current branch
  • Loading branch information...
commit 9af5ba2b66989a2706532fd92e1d14819b12e5a0 1 parent d98b276
@sshirokov sshirokov authored committed
Showing with 12 additions and 4 deletions.
  1. +12 −4 gogogo/server.py
View
16 gogogo/server.py
@@ -36,8 +36,15 @@ def branches(game):
pass
@app.get('/game/:name#[0-9a-f]+#/branch/', name='game-branch-current')
-def current_branch(game):
- pass
+def current_branch(name):
+ try:
+ game = Game(name)
+ return {'message': '',
+ 'data': game.branch()}
+ except GameError:
+ bottle.response.status = 404
+ return {'message': 'Game does not exist'}
+
@app.post('/game/:name#[0-9a-f]+#/branches/create/', name='game-branches-create')
def create_branch(game):
@@ -55,9 +62,10 @@ def game(name, branch):
def game(name):
try:
game = Game(name)
- return game.board.take_snapshot()
+ return {'message': '',
+ 'turn': game.board.player_turn(),
+ 'data': game.board.take_snapshot()}
except GameError:
- bottle.response.content_type = 'application/json'
bottle.response.status = 404
return {'message': 'Game does not exist'}
Please sign in to comment.
Something went wrong with that request. Please try again.