<commit_before>from werkzeug.exceptions import Gone
from flask import Blueprint, request
from restpager import Pager

from tmi.model import db, Card
from tmi.util import jsonify, obj_or_404, request_data


blueprint = Blueprint('cards_api', __name__)


@blueprint.route('/api/1/categories', methods=['GET'])
def categories():
    return jsonify({'categories': Card.CATEGORIES}, index=True)


@blueprint.route('/api/1/cards', methods=['GET'])
def index():
    cards = db.session.query(Card)
    pager = Pager(cards)
    return jsonify(pager, index=True)


@blueprint.route('/api/1/cards', methods=['POST', 'PUT'])
def create():
    return jsonify({}, status=201)


@blueprint.route('/api/1/cards/<id>', methods=['GET'])
def view(id):
    card = obj_or_404(Card.by_id(id))
    return jsonify(card)


@blueprint.route('/api/1/cards/<id>', methods=['POST', 'PUT'])
def update(id):
    card = obj_or_404(Card.by_id(id))
    return jsonify(card)


@blueprint.route('/api/1/cards/<id>', methods=['DELETE'])
def delete(id):
    card = obj_or_404(Card.by_id(id))
    raise Gone()<commit_msg>get data in cards api <commit_after>from werkzeug.exceptions import Gone
from flask import Blueprint
from restpager import Pager

from tmi.model import db, Card
from tmi.util import jsonify, obj_or_404, request_data


blueprint = Blueprint('cards_api', __name__)


@blueprint.route('/api/1/categories', methods=['GET'])
def categories():
    return jsonify({'categories': Card.CATEGORIES}, index=True)


@blueprint.route('/api/1/cards', methods=['GET'])
def index():
    cards = db.session.query(Card)
    pager = Pager(cards)
    return jsonify(pager, index=True)


@blueprint.route('/api/1/cards', methods=['POST', 'PUT'])
def create():
    data = request_data()
    return jsonify({}, status=201)


@blueprint.route('/api/1/cards/<id>', methods=['GET'])
def view(id):
    card = obj_or_404(Card.by_id(id))
    return jsonify(card)


@blueprint.route('/api/1/cards/<id>', methods=['POST', 'PUT'])
def update(id):
    card = obj_or_404(Card.by_id(id))
    data = request_data()
    return jsonify(card)


@blueprint.route('/api/1/cards/<id>', methods=['DELETE'])
def delete(id):
    card = obj_or_404(Card.by_id(id))
    
    raise Gone()
{'fraction_non_alphanumeric': 0.17424583520936515, 'fraction_numerical': 0.01891040072039622, 'mean_word_length': 4.816753926701571, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5250145', 'n_tokens_mistral': 819, 'n_tokens_neox': 790, 'n_words': 165}