<commit_before>import json

from app import app
from flask import render_template, request, jsonify

from api import TagCore, AppDataCore
from utils import FileIO

def setToList(obj):
    if isinstance(obj, set):
        return list(obj)
    raise TypeError

@app.route('/')
@app.route('/index')
def index():
    return render_template('index.html')

@app.route('/load', methods=['GET'])
def readfile():
    rawContent = None
    filePath = request.args.get('file_path')
    error, response = FileIO.readFile(filePath)

    if error:
        response = None

    return jsonify(response=response, error=error)

@app.route('/act/<profile>/<tag>', methods=['POST'])
def addTag(tag, profile):
    error, response = None, None
    action = request.form.get('action')
    
    if action == 'add':
        error, response = TagCore.addTag(tag, profile)
    elif action == 'delete':
        error, response = TagCore.removeTag(tag, profile)
    
    if error:
        response = None

    return jsonify(response=response, error=error)

@app.route('/act/<profile>', methods=['POST'])
def addProfile(profile):
    error, response = None, None
    action = request.form.get('action')
    
    if action == 'add':
        error, response = TagCore.addProfile(profile)
    elif action == 'delete':
        error, response = TagCore.removeProfile(profile)

    if error:
        response = None

    return jsonify(response=response, error=error)

@app.route('/data/<key>', methods=['GET'])
def getAppData(key):
    error, response = None, None
    response = AppDataCore.getAppDataForKey(key)

    if response == None:
        error = 'Invalid data requested'

    print response, error
    return jsonify(response=response, error=error)

@app.route('/data/profile/<profileName>', methods=['GET'])
def getProfileInfo(profileName):
    error, response = None, None
    appData = AppDataCore.getAppData()
    response = appData['profile'].get(profileName, None)

    if response == None:
        error = 'Profile %s does not exist.' % (profileName)

    return jsonify(response=response, error=error)<commit_msg>fixed #7: Added the logging statements to views<commit_after>import json

from app import app
from flask import render_template, request, jsonify

from api import TagCore, AppDataCore

from utils import FileIO
from ..utils.logger import logger

def setToList(obj):
    if isinstance(obj, set):
        return list(obj)
    raise TypeError

@app.route('/')
@app.route('/index')
def index():
    logger.info('Hitting URL %s', request.url)
    return render_template('index.html')

@app.route('/load', methods=['GET'])
def readfile():
    logger.info('Hitting URL %s', request.url)

    rawContent = None
    filePath = request.args.get('file_path')
    error, response = FileIO.readFile(filePath)

    if error:
        response = None

    logger.debug('Error: %s', error)
    logger.debug('Response: %s', response)
    return jsonify(response=response, error=error)

@app.route('/act/<profile>/<tag>', methods=['POST'])
def addTag(tag, profile):
    logger.info('Hitting URL %s', request.url)

    error, response = None, None
    action = request.form.get('action')
    
    if action == 'add':
        error, response = TagCore.addTag(tag, profile)
    elif action == 'delete':
        error, response = TagCore.removeTag(tag, profile)
    
    if error:
        response = None

    logger.debug('Error: %s', error)
    logger.debug('Response: %s', response)
    return jsonify(response=response, error=error)

@app.route('/act/<profile>', methods=['POST'])
def addProfile(profile):
    logger.info('Hitting URL %s', request.url)

    error, response = None, None
    action = request.form.get('action')
    
    if action == 'add':
        error, response = TagCore.addProfile(profile)
    elif action == 'delete':
        error, response = TagCore.removeProfile(profile)

    if error:
        response = None

    logger.debug('Error: %s', error)
    logger.debug('Response: %s', response)
    return jsonify(response=response, error=error)

@app.route('/data/<key>', methods=['GET'])
def getAppData(key):
    logger.info('Hitting URL %s', request.url)

    error, response = None, None
    response = AppDataCore.getAppDataForKey(key)

    if response == None:
        error = 'Invalid data requested'

    logger.debug('Error: %s', error)
    logger.debug('Response: %s', response)
    return jsonify(response=response, error=error)

@app.route('/data/profile/<profileName>', methods=['GET'])
def getProfileInfo(profileName):
    logger.info('Hitting URL %s', request.url)

    error, response = None, None
    appData = AppDataCore.getAppData()
    response = appData['profile'].get(profileName, None)

    if response == None:
        error = 'Profile %s does not exist.' % (profileName)

    logger.debug('Error: %s', error)
    logger.debug('Response: %s', response)
    return jsonify(response=response, error=error)
{'fraction_non_alphanumeric': 0.14082792207792208, 'fraction_numerical': 0.00020292207792207794, 'mean_word_length': 3.589385474860335, 'pattern_counts': {'":': 0, '<': 13, '<?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': '5341685', 'n_tokens_mistral': 1499, 'n_tokens_neox': 1481, 'n_words': 389}