<commit_before>from flask import Flask, jsonify
from gestion.database import session, init_database
from gestion.views import Group


app = Flask(__name__)


@app.cli.command
def initdb():
    """DB初期化コマンド."""
    init_db()


@app.teardown_appcontext
def shutdown_session(exception=None):
    """リクエスト終了時の処理."""
    session.remove() # DBとの接続を切る


@app.route('/')
def hello():
    return "Hello, Gestion!"

##### エラーレスポンス (JSON化) ###
@app.errorhandler(400)
def bad_request(err):
    return jsonify(message=err.description)


@app.errorhandler(401)
def unauthorize(err):
    return jsonify(message=err.description)


@app.errorhandler(403)
def forbidden(err):
    return jsonify(message=err.description)


@app.errorhandler(404)
def not_found(err):
    return jsonify(message=err.description)


@app.errorhandler(405)
def method_not_allowed(err):
    return jsonify(message=err.description)


@app.errorhandler(409)
def conflict(err):
    return jsonify(message=err.description)


@app.errorhandler(500)
def internal_server_error(err):
    return jsonify(message=err.description)


app.add_url_rule('/groups', view_func=Group.as_view('groups'), methods=['POST',])<commit_msg>エラーコードをレスポンスに含める<commit_after>from flask import Flask, jsonify
from gestion.database import session, init_database
from gestion.views import Group


app = Flask(__name__)


@app.cli.command
def initdb():
    """DB初期化コマンド."""
    init_db()


@app.teardown_appcontext
def shutdown_session(exception=None):
    """リクエスト終了時の処理."""
    session.remove() # DBとの接続を切る


@app.route('/')
def hello():
    return "Hello, Gestion!"

##### エラーレスポンス (JSON化) ###
@app.errorhandler(400)
def bad_request(err):
    return jsonify(code=err.code, message=err.description)


@app.errorhandler(401)
def unauthorize(err):
    return jsonify(code=err.code, message=err.description)


@app.errorhandler(403)
def forbidden(err):
    return jsonify(code=err.code, message=err.description)


@app.errorhandler(404)
def not_found(err):
    return jsonify(code=err.code, message=err.description)


@app.errorhandler(405)
def method_not_allowed(err):
    return jsonify(code=err.code, message=err.description)


@app.errorhandler(409)
def conflict(err):
    return jsonify(code=err.code, message=err.description)


@app.errorhandler(500)
def internal_server_error(err):
    return jsonify(code=err.code, message=err.description)


app.add_url_rule('/groups', view_func=Group.as_view('groups'), methods=['POST',])
{'fraction_non_alphanumeric': 0.14140179299103506, 'fraction_numerical': 0.017114914425427872, 'mean_word_length': 5.763085399449036, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7015342', 'n_tokens_mistral': 926, 'n_tokens_neox': 876, 'n_words': 152}