<commit_before>from flask import render_template, redirect, url_for, request, session
from flask.json import dumps
from flask.ext.login import current_user
from . import heatmap
from .forms import SelectFiles
from ..models import Bed
from .models import Heatmap


@heatmap.route('/', methods=['GET', 'POST'])
def base():

    # create 'select_files' object from 'SelectFiles' class
    select_files = SelectFiles()

    # order the selection process to display only desired files
    select_files.pfiles.choices = [(f.file_location, f.label)
                                   for f in Bed.query.filter_by(user='public')]

    # display user data if logged in and confirmed
    if current_user.is_authenticated \
       and current_user.confirmed:
        select_files.ufiles.choices = [(f.file_location, f.label)
                                      for f in Bed.query.filter_by(user=getattr(current_user, "username"))]

    # process that occurs after file is selected and form is submitted
    if select_files.validate_on_submit():
        session['files_selected'] = select_files.pfiles.data + select_files.ufiles.data
        session['stat_method'] = select_files.methods.data

        # create 'colocalization_output' object
        colocalization_output = Heatmap(
            session['files_selected'], select_files.methods.data)

        # determine_method selected by user and generate answer
        output = colocalization_output.determine_method()

        # dump data and set to heatmapJson
        heatmapJson = dumps({'nodes' : output[0], 'links': output[1]})
        
        # with session cookie set redirect to success
        return render_template('heatmap/success.html', heatmapData=heatmapJson)
    return render_template('heatmap/index.html', form=select_files)


@heatmap.route('/success', methods=['GET', 'POST'])
def success():
    return render_template('heatmap/success.html')<commit_msg>fix NoneType error when looking at public<commit_after>from flask import render_template, redirect, url_for, request, session
from flask.json import dumps
from flask.ext.login import current_user
from . import heatmap
from .forms import SelectFiles
from ..models import Bed
from .models import Heatmap


@heatmap.route('/', methods=['GET', 'POST'])
def base():

    # create 'select_files' object from 'SelectFiles' class
    select_files = SelectFiles()

    # order the selection process to display only desired files
    select_files.pfiles.choices = [(f.file_location, f.label)
                                   for f in Bed.query.filter_by(user='public')]

    # display user data if logged in and confirmed
    if current_user.is_authenticated \
       and current_user.confirmed:
        select_files.ufiles.choices = [(f.file_location, f.label)
                                      for f in Bed.query.filter_by(user=getattr(current_user, "username"))]
    else:
        select_files.ufiles.choices = []

    # process that occurs after file is selected and form is submitted
    if select_files.validate_on_submit():
        session['files_selected'] = select_files.pfiles.data + select_files.ufiles.data
        session['stat_method'] = select_files.methods.data

        # create 'colocalization_output' object
        colocalization_output = Heatmap(
            session['files_selected'], select_files.methods.data)

        # determine_method selected by user and generate answer
        output = colocalization_output.determine_method()

        # dump data and set to heatmapJson
        heatmapJson = dumps({'nodes' : output[0], 'links': output[1]})
        
        # with session cookie set redirect to success
        return render_template('heatmap/success.html', heatmapData=heatmapJson)
    return render_template('heatmap/index.html', form=select_files)


@heatmap.route('/success', methods=['GET', 'POST'])
def success():
    return render_template('heatmap/success.html')
{'fraction_non_alphanumeric': 0.09548123563952005, 'fraction_numerical': 0.0010211896859841716, 'mean_word_length': 3.263329706202394, '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': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5152340', 'n_tokens_mistral': 1097, 'n_tokens_neox': 1048, 'n_words': 297}