def login1():
    error = None
    global username
    global name2
    global class2
    username = request.form['username']
    password = request.form['password']
    logdata = pr.login(username, password)

    if request.method == 'POST':
        if logdata[0] == 2:
            name2 = logdata[2]
            class2 = logdata[3]
            session['logged_in'] = True
            return render_template('index2.html',
                                   user=username,
                                   name=name2,
                                   class1=class2)
        elif logdata[0] == 0:
            session['logged_in'] = True
            pr.reload()
            classlist = pr.get_all_classes()
            return render_template('aboutadminmain.html',
                                   user=username,
                                   list=classlist)
        elif logdata[0] == 1:
            session['logged_in'] = True
            return render_template("aboutteacher.html", user=username)
        else:
            error = 'Invalid Credentials. Please try again.'
    return render_template('login.html', error=error)
def upload_file():
    target = os.path.join(APP_ROOT, 'SHEETS/')
    print(target)

    for file in request.files.getlist("file"):
        print(file)
        filename = file.filename
        destination = "/".join([target, filename])
        print(destination)
        file.save(destination)
    pr.reload()
    return render_template("about.html")
def index():
    logdata = pr.login(username, password)
    if not session.get('logged_in'):
        return render_template('login.html')

    elif logdata[0] == 2:
        session['logged_in'] = True
        return render_template('index2.html', user=username)

    elif logdata[0] == 1:
        session['logged_in'] = True

        return render_template("aboutteacher.html", user=username)
    else:
        pr.reload()
        classlist = pr.get_all_classes()

    return render_template("aboutadminmain.html",
                           list=classlist,
                           user=username)
def about():
    pr.reload()
    return render_template("about.html")
def aboutteacher():
    pr.reload()
    return render_template("aboutteacher.html")
def aboutadminmain():
    pr.reload()
    classlist = pr.get_all_classes()
    return render_template("aboutadminmain.html", list=classlist)