<commit_before>from flask import (Flask, render_template, request,
                    flash, redirect, url_for)
from flask_login import (LoginManager, login_user,
                        logout_user, login_required )
from sql import SQLConnection
from user import User

app = Flask(__name__)
app.secret_key = '<KEY>'

#login manager
loginManager = LoginManager()

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


@app.route("/login", methods=['GET', 'POST'])
def login():
    #if someone tried to login
    if request.method == 'POST':
        alias = request.form['alias'].encode("UTF-8")
        #password = request.form['password'].encode("<PASSWORD>")

        user = User(alias)
        if user is not None:    #if valid user
            login_user(user)
            #show login msg
            flash('You are now logged in!')

            return redirect(request.args.get('next') or url_for('index'))


    #cursor.callproc('uspAllowAgent', ('zeth',))

    #for row in cursor:
    #    print("return = %r" % (row,))

    return render_template('login.html')

@app.route("/logout")
@login_required
def logout():
    logout_user()
    return redirect(url_for('login'))

@app.route("/userPage")
@login_required
def userPage():
    return render_template('userPage.html')

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

#Admin stuff
@app.route("/newAgent")
def newAgent():
    return render_template('newAgent.html')

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

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

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

#Agent stuff

#Listing stuff
@app.route("/showListings")
def showListings():
    return render_template('showListings.html')


#get user's id
@loginManager.user_loader
def load_user(userid):
    return User(userid)

@loginManager.unauthorized_handler
def unauthorized():
    flash("You are not logged in!")<commit_msg>added login required protection to some pages<commit_after>from flask import (Flask, render_template, request,
                    flash, redirect, url_for)
from flask_login import (LoginManager, login_user,
                        logout_user, login_required )
from sql import SQLConnection
from user import User

app = Flask(__name__)
app.secret_key = '<KEY>'

#login manager
loginManager = LoginManager()

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


@app.route("/login", methods=['GET', 'POST'])
def login():
    #if someone tried to login
    if request.method == 'POST':
        alias = request.form['alias'].encode("UTF-8")
        #password = request.form['password'].encode("<PASSWORD>")

        user = User(alias)
        if user is not None:    #if valid user
            login_user(user)
            #show login msg
            flash('You are now logged in!')

            return redirect(request.args.get('next') or url_for('index'))


    #cursor.callproc('uspAllowAgent', ('zeth',))

    #for row in cursor:
    #    print("return = %r" % (row,))

    return render_template('login.html')

@app.route("/logout")
@login_required
def logout():
    logout_user()
    return redirect(url_for('login'))

@app.route("/userPage")
@login_required
def userPage():
    return render_template('userPage.html')

@app.route("/newListing")
@login_required
def newListing():
    return render_template('newListing.html')

#Admin stuff
@app.route("/newAgent")
@login_required
def newAgent():
    return render_template('newAgent.html')

@app.route("/modifyAgent")
@login_required
def modifyAgent():
    return render_template('modifyAgent.html')

@app.route("/reactivateAgent")
@login_required
def reactivateAgent():
    return render_template('reactivateAgent.html')

@app.route("/suspendAgent")
@login_required
def suspendAgent():
    return render_template('suspendAgent.html')

#Agent stuff

#Listing stuff
@app.route("/showListings")
@login_required
def showListings():
    return render_template('showListings.html')


#get user's id
@loginManager.user_loader
def load_user(userid):
    return User(userid)

@loginManager.unauthorized_handler
def unauthorized():
    flash("You are not logged in!")
{'fraction_non_alphanumeric': 0.13788364635822262, 'fraction_numerical': 0.0004580852038479157, 'mean_word_length': 4.002290950744559, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '194232', 'n_tokens_mistral': 1329, 'n_tokens_neox': 1301, 'n_words': 319}