<commit_before>from app import app, models, db
from flask import jsonify, abort, request

app.url_map.strict_slashes = False

@app.route('/post/', methods=['GET'])
@app.route('/post/<int:post_id>', methods=['GET'])
def get_post(post_id=None):
    """Searches the database for entries, then displays them."""
    if post_id is None:
        posts = db.session.query(models.Post)
        posts_json = [post.json() for post in posts]
        return jsonify({'status' : 'ok'}, {'posts' : posts_json})
    else:
        post = models.Post.query.get(post_id)

        if post is None:
            return jsonify({'status' : 'failed'}), 400

        post_json = post.json()
        return jsonify({'status' : 'ok'}, {'post' : post_json})


@app.route('/post/', methods=['POST'])
def add_post():
    """Adds new post to the database."""
    content = request.json.get('text', '')
    if len(content) > 140 or len(content) == 0:
        return jsonify({'status' : 'failed'}), 400 

    post = models.Post(content)
    db.session.add(post)
    db.session.commit()

    return jsonify({'status' : 'ok'}, {'post' : post.json()}), 201

@app.route('/post/<int:post_id>', methods=['PUT'])
def edit_post(post_id):
    """Edit post in the database."""
    post = models.Post.query.get(post_id)
    content = request.json.get('text', '')

    if post is None or len(content) > 140 or len(content) == 0:
        return jsonify({'status' : 'failed'}), 400

    post.text = content
    db.session.commit()

    return jsonify({'status' : 'ok'}, {'post' : post.json()}), 201

@app.route('/post/<int:post_id>', methods=['DELETE'])
def remove_post(post_id):
    """Delete post in the database."""
    post = models.Post.query.get(post_id)

    if post is None:
        return jsonify({'status' : 'failed'}), 400

    db.session.delete(post)
    db.session.commit()

    return jsonify({'status' : 'ok'}), 201<commit_msg>DELETE Status fixed<commit_after>from app import app, models, db
from flask import jsonify, abort, request

app.url_map.strict_slashes = False

@app.route('/post/', methods=['GET'])
@app.route('/post/<int:post_id>', methods=['GET'])
def get_post(post_id=None):
    """Searches the database for entries, then displays them."""
    if post_id is None:
        posts = db.session.query(models.Post)
        posts_json = [post.json() for post in posts]
        return jsonify({'status' : 'ok'}, {'posts' : posts_json})
    else:
        post = models.Post.query.get(post_id)

        if post is None:
            return jsonify({'status' : 'failed'}), 400

        post_json = post.json()
        return jsonify({'status' : 'ok'}, {'post' : post_json})


@app.route('/post/', methods=['POST'])
def add_post():
    """Adds new post to the database."""
    content = request.json.get('text', '')
    if len(content) > 140 or len(content) == 0:
        return jsonify({'status' : 'failed'}), 400 

    post = models.Post(content)
    db.session.add(post)
    db.session.commit()

    return jsonify({'status' : 'ok'}, {'post' : post.json()}), 201

@app.route('/post/<int:post_id>', methods=['PUT'])
def edit_post(post_id):
    """Edit post in the database."""
    post = models.Post.query.get(post_id)
    content = request.json.get('text', '')

    if post is None or len(content) > 140 or len(content) == 0:
        return jsonify({'status' : 'failed'}), 400

    post.text = content
    db.session.commit()

    return jsonify({'status' : 'ok'}, {'post' : post.json()}), 201

@app.route('/post/<int:post_id>', methods=['DELETE'])
def remove_post(post_id):
    """Delete post in the database."""
    post = models.Post.query.get(post_id)

    if post is None:
        return jsonify({'status' : 'failed'}), 400

    db.session.delete(post)
    db.session.commit()

    return jsonify({'status' : 'ok'}), 200
{'fraction_non_alphanumeric': 0.1837809373354397, 'fraction_numerical': 0.015271195365982097, 'mean_word_length': 3.312145289443814, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, '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': '5959124', 'n_tokens_mistral': 1321, 'n_tokens_neox': 1242, 'n_words': 313}