<commit_before>#! /usr/bin/env python
# -*- coding: UTF-8 -*-
#

from __future__ import absolute_import

from flask import (
    Flask, redirect, request, render_template, url_for, session, jsonify
)

import traceback

import oclubs
from oclubs.userblueprint import userblueprint
from oclubs.clubblueprint import clubblueprint
from oclubs.actblueprint import actblueprint

from oclubs.redissession import RedisSessionInterface

app = Flask(__name__)

app.register_blueprint(userblueprint, url_prefix='/user')
app.register_blueprint(clubblueprint, url_prefix='/club')
app.register_blueprint(actblueprint, url_prefix='/act')

app.session_interface = RedisSessionInterface()


@app.errorhandler(404)
@app.route('/404')
def wrong_url():
    if 'user_id' in session:
        user = oclubs.objs.User(session['user_id']).nickname
    else:
        user = ''
    return render_template('wrongurl.html',
                           title='Wrong URL',
                           user=user
                           ), 404


@app.errorhandler(403)
def no_access():
    user_obj = oclubs.objs.User(session['user_id'])
    return render_template('noaccess.html',
                           title='No Access',
                           user=user_obj.nickname
                           ), 403


@app.errorhandler(401)
def not_logged_in():
    return render_template('notloggedin.html',
                           title='Not Logged In',
                           user=''
                           ), 401


@app.route('/login', methods=['POST'])
def login():
    '''API to login'''
    if 'user_id' in session:
        status = 'loggedin'
    else:
        user = oclubs.objs.User.attempt_login(
            request.form['username'],
            request.form['password']
        )
        if user is not None:
            session['user_id'] = user.id
            status = 'success'
        else:
            status = 'failure'
    return jsonify({'result': status})


@app.route('/')
def homepage():<commit_msg>errorhandlers adjusted<commit_after>#! /usr/bin/env python
# -*- coding: UTF-8 -*-
#

from __future__ import absolute_import

from flask import (
    Flask, redirect, request, render_template, url_for, session, jsonify
)

import traceback

import oclubs
from oclubs.userblueprint import userblueprint
from oclubs.clubblueprint import clubblueprint
from oclubs.actblueprint import actblueprint

from oclubs.redissession import RedisSessionInterface

app = Flask(__name__)

app.register_blueprint(userblueprint, url_prefix='/user')
app.register_blueprint(clubblueprint, url_prefix='/club')
app.register_blueprint(actblueprint, url_prefix='/act')

app.session_interface = RedisSessionInterface()


@app.errorhandler(404)
@app.route('/404')
def wrong_url(e):
    if 'user_id' in session:
        user = oclubs.objs.User(session['user_id']).nickname
    else:
        user = ''
    return render_template('wrongurl.html',
                           title='Wrong URL',
                           user=user
                           ), 404


@app.errorhandler(403)
def no_access(e):
    user_obj = oclubs.objs.User(session['user_id'])
    return render_template('noaccess.html',
                           title='No Access',
                           user=user_obj.nickname
                           ), 403


@app.errorhandler(401)
def not_logged_in(e):
    return render_template('notloggedin.html',
                           title='Not Logged In',
                           user=''
                           ), 401


@app.route('/login', methods=['POST'])
def login():
    '''API to login'''
    if 'user_id' in session:
        status = 'loggedin'
    else:
        user = oclubs.objs.User.attempt_login(
            request.form['username'],
            request.form['password']
        )
        if user is not None:
            session['user_id'] = user.id
            status = 'success'
        else:
            status = 'failure'
    return jsonify({'result': status})


@app.route('/')
def homepage():
{'fraction_non_alphanumeric': 0.11526946107784432, 'fraction_numerical': 0.010978043912175649, 'mean_word_length': 2.2914614121510675, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1916756', 'n_tokens_mistral': 1230, 'n_tokens_neox': 1175, 'n_words': 248}