<commit_before># -*- encoding: utf-8 -*-
from flask import render_template, redirect, url_for, abort, request, session, flash, Blueprint

from webapp.config import view_conf
from webapp.service.cwr import LocalCWRFileService
from webapp.service.match import LocalMatchingService
from webapp.service.pagination import DefaultPaginationService

__author__ = '<NAME>'
__license__ = 'MIT'
__status__ = 'Development'

cwr_blueprint = Blueprint('cwr', __name__,
                          template_folder='templates',
                          static_folder='static')

PER_PAGE = view_conf.per_page

cwr_service = LocalCWRFileService()
match_service = LocalMatchingService()
pagination_service = DefaultPaginationService()

"""
Upload routes.
"""


@cwr_blueprint.route('/upload', methods=['GET'])
def upload():
    return render_template('upload_cwr.html')


@cwr_blueprint.route('/upload/cwr', methods=['POST'])
def upload_handler():
    # Get the name of the uploaded file
    sent_file = request.files['file']

    if sent_file:
        file_id = cwr_service.save_file(sent_file)

        session['cwr_file_id'] = file_id

        return redirect(url_for('.validation_report'))
    else:
        flash('No file selected')
        return redirect(url_for('.upload_cwr'))


"""
CWR matching routes.
"""


@cwr_blueprint.route('/match', methods=['GET'])
def match():
    sources = match_service.get_sources()
    return render_template('match.html', sources=sources)


@cwr_blueprint.route('/match/report', methods=['GET'])
def match_report():
    result = {}

    result['pairs'] = match_service.get_match_pairs()

    return render_template('match_result.html', result=result)


@cwr_blueprint.route('/match/report/download', methods=['GET'])
def match_report_download():
    return redirect(url_for('.match_report'))
<commit_msg>Cleaned up upload routes.<commit_after># -*- encoding: utf-8 -*-
from flask import render_template, redirect, url_for, abort, request, session, flash, Blueprint

from webapp.config import view_conf
from webapp.service.cwr import LocalCWRFileService
from webapp.service.match import LocalMatchingService
from webapp.service.pagination import DefaultPaginationService

__author__ = '<NAME>'
__license__ = 'MIT'
__status__ = 'Development'

cwr_blueprint = Blueprint('cwr', __name__,
                          template_folder='templates',
                          static_folder='static')

PER_PAGE = view_conf.per_page

cwr_service = LocalCWRFileService()
match_service = LocalMatchingService()
pagination_service = DefaultPaginationService()

"""
Upload routes.
"""


@cwr_blueprint.route('/upload', methods=['GET'])
def upload():
    return render_template('upload_cwr.html')


@cwr_blueprint.route('/upload', methods=['POST'])
def upload_handler():
    # Get the name of the uploaded file
    sent_file = request.files['file']

    if sent_file:
        file_id = cwr_service.save_file(sent_file)

        session['cwr_file_id'] = file_id

        return redirect(url_for('.validation_report'))
    else:
        flash('No file selected')
        return redirect(url_for('.upload'))


"""
CWR matching routes.
"""


@cwr_blueprint.route('/match', methods=['GET'])
def match():
    sources = match_service.get_sources()
    return render_template('match.html', sources=sources)


@cwr_blueprint.route('/match/report', methods=['GET'])
def match_report():
    result = {}

    result['pairs'] = match_service.get_match_pairs()

    return render_template('match_result.html', result=result)


@cwr_blueprint.route('/match/report/download', methods=['GET'])
def match_report_download():
    return redirect(url_for('.match_report'))

{'fraction_non_alphanumeric': 0.12964989059080964, 'fraction_numerical': 0.0005470459518599562, 'mean_word_length': 4.474550898203593, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6169471', 'n_tokens_mistral': 1121, 'n_tokens_neox': 1092, 'n_words': 227}