from flask import render_template, abort, redirect, url_for, abort, flash, request, current_app, make_response, g
from flask_login import login_required, login_user, logout_user, current_user
#from flask_sqlalchemy import get_recorded_queries

from . import main
from .forms import LoginForm, RegistrationForm

from mailsender import send_email
from models import db, User, Permission, Item

import base64

#@main.after_app_request
#def after_request(response):
#    for query in get_recorded_queries():
#        if query.duration >= current_app.config['SLOW_DB_QUERY_TIME']:
#            current_app.logger.warning('Slow query: %s\nParameters: %s\nDuration: %fs\nContext: %s\n' % (query.statement, query.parameters, query.duration, query.context))
#    return response

#STATIC PAGES
@main.route("/", methods=['GET'])
def index():
    form = LoginForm()
    return render_template('main/index.html', form=form)

@main.route("/aboutus", methods=['GET'])
def about():
    return render_template('main/aboutus.html')

@main.route("/terms", methods=['GET'])
def terms():
    return render_template('main/terms.html')
