Permalink
Browse files

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

…current branch
  • Loading branch information...
1 parent d98b276 commit 9af5ba2b66989a2706532fd92e1d14819b12e5a0 @sshirokov sshirokov committed with Nov 25, 2010
Showing with 12 additions and 4 deletions.
  1. +12 −4 gogogo/server.py
View
@@ -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'}

0 comments on commit 9af5ba2

Please sign in to comment.