<commit_before>from flask import (Flask, render_template, request, redirect,
                   url_for, flash)
from flaskext.uploads import (UploadSet, configure_uploads, ARCHIVES,
                              UploadConfiguration)
import os
import zipfile


app = Flask(__name__)
app.config.from_pyfile('config.py')

uploaded_files = UploadSet('tracks', ARCHIVES,
                           default_dest=lambda app: app.instance_path)
configure_uploads(app, uploaded_files)

UPLOAD_DEST = os.path.join(os.path.abspath(os.path.dirname(__file__)),
                           'static/data')
uploaded_files._config = UploadConfiguration(UPLOAD_DEST)

configure_uploads(app, uploaded_files)


@app.route('/')
def index():
    print os.path.abspath(__file__)
    return render_template('index.html')


@app.route('/upload', methods=['POST', 'GET'])
def upload():
    if request.method == "POST":
        filename = uploaded_files.save(request.files.get('track'))
        extract_file(filename)
        flash('Your upload was successful.')
        return redirect(url_for('upload'))
    return render_template('upload.html')


def extract_file(name):
    """TODO: Insert assertions for error handling."""
    zipF = zipfile.ZipFile(os.path.join(UPLOAD_DEST, name))
    zipF.extractall(os.path.join(UPLOAD_DEST, 'extracted_data'))

if __name__ == "__main__":
    app.run('localhost', 5000, True)<commit_msg>Code refactor.<commit_after>from flask import (Flask, render_template, request, redirect,
                   url_for, flash)
from flaskext.uploads import (UploadSet, configure_uploads, ARCHIVES,
                              UploadConfiguration)
import os
import zipfile


app = Flask(__name__)
app.config.from_pyfile('config.py')

uploaded_files = UploadSet('tracks', ARCHIVES,
                           default_dest=lambda app: app.instance_path)
configure_uploads(app, uploaded_files)

UPLOAD_DEST = os.path.join(os.path.abspath(os.path.dirname(__file__)),
                           'static/data')
uploaded_files._config = UploadConfiguration(UPLOAD_DEST)

configure_uploads(app, uploaded_files)


@app.route('/')
def index():
    print os.path.abspath(__file__)
    return render_template('index.html')


@app.route('/upload', methods=['POST', 'GET'])
def upload():
    if request.method == "POST":
        filename = uploaded_files.save(request.files.get('track'))
        extract_file(filename)
        flash('Your upload was successful.')
        return redirect(url_for('upload'))
    return render_template('upload.html')


def extract_file(name):
    """TODO: Insert assertions for error handling."""
    with zipfile.ZipFile(os.path.join(UPLOAD_DEST, name)) as zipF:
        zipF.extractall(os.path.join(UPLOAD_DEST, 'extracted_data'))


if __name__ == "__main__":
    app.run('localhost', 5000, True)
{'fraction_non_alphanumeric': 0.1261101243339254, 'fraction_numerical': 0.002841918294849023, 'mean_word_length': 3.5788617886178864, 'pattern_counts': {'":': 4, '<': 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': '5728415', 'n_tokens_mistral': 894, 'n_tokens_neox': 869, 'n_words': 168}