Merge pull request #16 from sorrelbri/sj-serve-game

serve basic game data
This commit is contained in:
sorrelbri 2019-10-11 11:56:42 -07:00 committed by GitHub
commit 63982a2615
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View file

@ -11,6 +11,14 @@ from websockets.socket import new_game_notice
api_games = Blueprint('api_games', __name__, url_prefix='/api/games') api_games = Blueprint('api_games', __name__, url_prefix='/api/games')
@api_games.route('/<game_id>', methods=['GET'])
def get_room(game_id):
print(game_id)
game = Game.query.filter_by(id=game_id).first()
response = game_schema.dumps(game)
# join_game_notice(game_id)
return jsonify(response)
@api_games.route('/', methods=['POST']) @api_games.route('/', methods=['POST'])
@jwt_required() @jwt_required()
def post_game(): def post_game():

View file

@ -77,7 +77,7 @@ class GameSchema(ma.ModelSchema):
id = fields.Int() id = fields.Int()
name = fields.Str() name = fields.Str()
description = fields.Str() description = fields.Str()
boardSize = fields.Int() board_size = fields.Int()
player = fields.Nested(user_schema) player = fields.Nested(user_schema)
game_schema = GameSchema() game_schema = GameSchema()