<commit_before>import json
from flask import Flask, request

from redir import DataStore

appname = "app"
recordstore = DataStore()

app = Flask(appname)
app.config.from_object(appname)

app.config.update(dict(
    DEBUG=True,
))

@app.route('/')
def index():
    return "Welcome to the 301-in-a-Box admin interface!\n"


@app.route('/api/records', methods=['GET'])
def get_records():
    """Get ALIAS records"""
    return json.dumps(recordstore.todict())

@app.route('/api/records/<record_id>', methods=['GET'])
def get_record(record_id):
    if record_id and record_id in recordstore:
        record = {}
        record[record_id] = recordstore[record_id]
        return json.dumps(record)
    else:
        return "No such record exists.\n"


@app.route('/api/records', methods=['POST'])
def post_record():
    """Add ALIAS record to database"""
    data = request.get_json()
    if not data:
        return "Error: Invalid JSON.\n"
    record = data['record']
    hostname = record['hostname']
    url = record['url']

    recordstore[hostname] = url
    response = '''
        Record created:
        {0} -> {1}
    '''.format(hostname, recordstore[hostname])
    return response


@app.route('/api/records/<record_id>', methods=['PUT'])
def put_record(record_id):
    """Update ALIAS record"""
    return "This will update an ALIAS record\n"


@app.route('/api/records/<record_id>', methods=['DELETE'])
def delete_record(record_id):
    """Delete ALIAS record from the database"""
    if record_id in recordstore:
        record = {}
        record[record_id] = recordstore[record_id]
        del recordstore[record_id]
        return "Deleted record: {0}\n".format(json.dumps(record))
    else:
        return "No such record exists.\n"



if __name__ == '__main__':
    app.run(host='0.0.0.0', port=8080)<commit_msg>Fix record display<commit_after>import json
from flask import Flask, request

from redir import DataStore

appname = "app"
recordstore = DataStore()

app = Flask(appname)
app.config.from_object(appname)

app.config.update(dict(
    DEBUG=True,
))

@app.route('/')
def index():
    return "Welcome to the 301-in-a-Box admin interface!\n"


@app.route('/api/records', methods=['GET'])
def get_records():
    """Get ALIAS records"""
    return json.dumps(recordstore.todict())

@app.route('/api/records/<record_id>', methods=['GET'])
def get_record(record_id):
    if record_id and record_id in recordstore:
        record = {}
        record['hostname'] = record_id
        record['url'] = recordstore[record_id]
        return json.dumps(record)
    else:
        return "No such record exists.\n"


@app.route('/api/records', methods=['POST'])
def post_record():
    """Add ALIAS record to database"""
    data = request.get_json()
    if not data:
        return "Error: Invalid JSON.\n"
    record = data['record']
    hostname = record['hostname']
    url = record['url']

    recordstore[hostname] = url
    response = '''
        Record created:
        {0} -> {1}
    '''.format(hostname, recordstore[hostname])
    return response


@app.route('/api/records/<record_id>', methods=['PUT'])
def put_record(record_id):
    """Update ALIAS record"""
    return "This will update an ALIAS record\n"


@app.route('/api/records/<record_id>', methods=['DELETE'])
def delete_record(record_id):
    """Delete ALIAS record from the database"""
    if record_id in recordstore:
        record = {}
        record = {}
        record['hostname'] = record_id
        record['url'] = recordstore[record_id]
        del recordstore[record_id]
        return "Deleted record: {0}\n".format(json.dumps(record))
    else:
        return "No such record exists.\n"



if __name__ == '__main__':
    app.run(host='0.0.0.0', port=8080)
{'fraction_non_alphanumeric': 0.15300400534045394, 'fraction_numerical': 0.007476635514018692, 'mean_word_length': 3.365967365967366, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '6047326', 'n_tokens_mistral': 1226, 'n_tokens_neox': 1212, 'n_words': 292}