<commit_before># -*- coding: utf-8 -*-

from flask import (Blueprint, request, render_template, flash, url_for,
                   redirect, session, jsonify)
from sqlalchemy.exc import IntegrityError

from fpage.models import User, Submission
from fpage.forms import RegisterForm, LoginForm
from fpage.utils import flash_errors
from fpage.models import db


blueprint = Blueprint('public', __name__,
                      static_folder="../static",
                      template_folder="../templates")


@blueprint.route("/", methods=["GET", "POST"])
def home():
    return render_template("page.html", posts=Submission.query.order_by(Submission.ups))


@blueprint.route('/logout/')
def logout():
    session.pop('logged_in', None)
    session.pop('username', None)
    flash('You are logged out.', 'info')
    return redirect(url_for('public.home'))


@blueprint.route("/login/", methods=['GET', 'POST'])
def login():
    form = LoginForm(request.form)
    if request.method == 'POST':
        u = User.query.filter_by(username=request.form['username']).first()
        if u is None or not u.check_password(request.form['password']):
            error = 'Invalid username or password.'
            return jsonify({"response": "error"})
        else:
            session['logged_in'] = True
            session['username'] = u.username
            flash("You are logged in.", 'success')
            return jsonify({"response": "Logged in"})
    return render_template("login.html", form=form)


@blueprint.route("/register/", methods=['GET', 'POST'])
def register():
    form = RegisterForm(request.form, csrf_enabled=False)
    if form.validate_on_submit():
        new_user = User(form.username.data, form.email.data, form.password.data)
        try:
            db.session.add(new_user)
            db.session.commit()
            flash("Thank you for registering. You can now log in.", 'success')
            return redirect(url_for('public.home'))
        except IntegrityError as err:
            flash("That username and/or email already exists. Try again.", 'warning')
    else:
        flash_errors(form)
    return render_template('register.html', form=form)


@blueprint.route("/about/")
def about():
    form = LoginForm(request.form)
    return render_template("about.html", form=form)
<commit_msg>Removed unecessary variable<commit_after># -*- coding: utf-8 -*-

from flask import (Blueprint, request, render_template, flash, url_for,
                   redirect, session, jsonify)
from sqlalchemy.exc import IntegrityError

from fpage.models import User, Submission
from fpage.forms import RegisterForm, LoginForm
from fpage.utils import flash_errors
from fpage.models import db


blueprint = Blueprint('public', __name__,
                      static_folder="../static",
                      template_folder="../templates")


@blueprint.route("/", methods=["GET", "POST"])
def home():
    return render_template("page.html", posts=Submission.query.order_by(Submission.ups))


@blueprint.route('/logout/')
def logout():
    session.pop('logged_in', None)
    session.pop('username', None)
    flash('You are logged out.', 'info')
    return redirect(url_for('public.home'))


@blueprint.route("/login/", methods=['GET', 'POST'])
def login():
    form = LoginForm(request.form)
    if request.method == 'POST':
        u = User.query.filter_by(username=request.form['username']).first()
        if u is None or not u.check_password(request.form['password']):
            return jsonify({"response": "error"})
        else:
            session['logged_in'] = True
            session['username'] = u.username
            flash("You are logged in.", 'success')
            return jsonify({"response": "Logged in"})
    return render_template("login.html", form=form)


@blueprint.route("/register/", methods=['GET', 'POST'])
def register():
    form = RegisterForm(request.form, csrf_enabled=False)
    if form.validate_on_submit():
        new_user = User(form.username.data, form.email.data, form.password.data)
        try:
            db.session.add(new_user)
            db.session.commit()
            flash("Thank you for registering. You can now log in.", 'success')
            return redirect(url_for('public.home'))
        except IntegrityError as err:
            flash("That username and/or email already exists. Try again.", 'warning')
    else:
        flash_errors(form)
    return render_template('register.html', form=form)


@blueprint.route("/about/")
def about():
    form = LoginForm(request.form)
    return render_template("about.html", form=form)

{'fraction_non_alphanumeric': 0.14210985178727115, 'fraction_numerical': 0.00043591979075850045, 'mean_word_length': 3.1120071684587813, 'pattern_counts': {'":': 4, '<': 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': '625622', 'n_tokens_mistral': 1318, 'n_tokens_neox': 1291, 'n_words': 321}