<commit_before>import locale
import os
import os.path

import cherrypy
from cherrypy import tools
from sqlalchemy import func
import json

from collector.models import Expense, Session


appdir = os.path.dirname(__file__)
if not appdir:
    appdir = '.'
appdir = os.path.abspath(appdir)


locale.setlocale(locale.LC_ALL, '')
locale.setlocale(locale.LC_MONETARY, 'pt_BR.UTF-8')


class DepWatchWeb(object):
    static = tools.staticdir.handler(section='static',
                                     root=appdir, dir='static')

    def index(self):
        return 'Hi!'
    index.exposed = True

    def per_nature(self):
        session = Session()

        expenses = session.query(Expense.nature,
                                 func.sum(Expense.expensed)).group_by(Expense.nature).all()

        tmp = expenses
        expenses = []
        total = 0

        for expense in tmp:
            total += expense[1]
            expenses.append((expense[0], expense[1]))

        expenses.append(('Total', total))

        return unicode(json.dumps(expenses))
    per_nature.exposed = True

cherrypy.quickstart(DepWatchWeb())<commit_msg>Redirect / to the actual page<commit_after>import locale
import os
import os.path

import cherrypy
from cherrypy import tools
from sqlalchemy import func
import json

from collector.models import Expense, Session


appdir = os.path.dirname(__file__)
if not appdir:
    appdir = '.'
appdir = os.path.abspath(appdir)


locale.setlocale(locale.LC_ALL, '')
locale.setlocale(locale.LC_MONETARY, 'pt_BR.UTF-8')


class DepWatchWeb(object):
    static = tools.staticdir.handler(section='static',
                                     root=appdir, dir='static')

    def index(self):
        raise cherrypy.HTTPRedirect('/static/index.html')
    index.exposed = True

    def per_nature(self):
        session = Session()

        expenses = session.query(Expense.nature,
                                 func.sum(Expense.expensed)).group_by(Expense.nature).all()

        tmp = expenses
        expenses = []
        total = 0

        for expense in tmp:
            total += expense[1]
            expenses.append((expense[0], expense[1]))

        expenses.append(('Total', total))

        return unicode(json.dumps(expenses))
    per_nature.exposed = True

cherrypy.quickstart(DepWatchWeb())
{'fraction_non_alphanumeric': 0.11020232458028412, 'fraction_numerical': 0.004304778303917348, 'mean_word_length': 2.55895865237366, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '760002', 'n_tokens_mistral': 719, 'n_tokens_neox': 679, 'n_words': 149}