<commit_before>import logging

from flask import request
from flask_restplus import Resource

from gameserver.game import Game
from gameserver.models import Player

from gameserver.api.restplus import api
from gameserver.api.serializers import player_get, player_post

from gameserver.database import db

db_session = db.session

log = logging.getLogger(__name__)

ns = api.namespace('players', description='Operations related to players')

game = Game()

@ns.route('/')
class PlayerCollection(Resource):

    @api.response(200, 'Success')
    @api.marshal_list_with(player_get)
    def get(self):
        """
        Returns list of players.
        """
        players = game.get_players()
        return players

    @api.response(201, 'Player successfully created.')
    @api.expect(player_post)
    def post(self):
        """
        Creates a new game player.
        """
        data = request.json
        player = game.create_player(data['name'])
        db_session.commit()
        return player.id, 201


@ns.route('/<string:id>')
@ns.param('id', 'The player id')
class Player(Resource):

    @api.response(404, 'Player not found')
    @api.response(200, 'Success')
    @api.marshal_with(player_get)
    def get(self, id):
        """                                                                                                                                                                            
        Returns the specified player.                                                                                                                                                       
        """
        player = game.get_player(id)
        if not player:
            api.abort(404)
        return player


<commit_msg>Return json, not just a string id<commit_after>import logging

from flask import request
from flask_restplus import Resource

from gameserver.game import Game
from gameserver.models import Player

from gameserver.api.restplus import api
from gameserver.api.serializers import player_get, player_post

from gameserver.database import db

db_session = db.session

log = logging.getLogger(__name__)

ns = api.namespace('players', description='Operations related to players')

game = Game()

@ns.route('/')
class PlayerCollection(Resource):

    @api.response(200, 'Success')
    @api.marshal_list_with(player_get)
    def get(self):
        """
        Returns list of players.
        """
        players = game.get_players()
        return players

    @api.response(201, 'Player successfully created.')
    @api.expect(player_post)
    def post(self):
        """
        Creates a new game player.
        """
        data = request.json
        player = game.create_player(data['name'])
        db_session.commit()
        return dict(id=player.id), 201


@ns.route('/<string:id>')
@ns.param('id', 'The player id')
class Player(Resource):

    @api.response(404, 'Player not found')
    @api.response(200, 'Success')
    @api.marshal_with(player_get)
    def get(self, id):
        """
        Returns the specified player.
        """
        player = game.get_player(id)
        if not player:
            api.abort(404)
        return player



{'fraction_non_alphanumeric': 0.10213032581453634, 'fraction_numerical': 0.011278195488721804, 'mean_word_length': 2.0009398496240602, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2997075', 'n_tokens_mistral': 886, 'n_tokens_neox': 836, 'n_words': 222}