proxadmin/app/main/routes.py

61 lines
2 KiB
Python
Raw Normal View History

2017-05-12 15:10:56 -04:00
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_debug_queries
2017-05-12 15:10:56 -04:00
from . import main
from .. import db
from ..email import send_email
2018-01-24 19:00:06 -05:00
from ..models import User, Permission, Server, Deployment, Service, Region, Address, Domain, contact_proxmaster
2017-07-15 00:28:04 -04:00
import base64
@main.after_app_request
def after_request(response):
for query in get_debug_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
2017-05-12 15:10:56 -04:00
#STATIC PAGES
@main.route("/", methods=['GET'])
def index():
2018-01-11 08:19:59 -05:00
allservers = Server.query.filter_by(enabled=True)
2018-01-09 06:05:45 -05:00
return render_template('main/index.html', servers=allservers)
2017-05-12 15:10:56 -04:00
@main.route("/chat", methods=['GET'])
def chat():
return render_template('main/livechat.html')
#@main.route("/aboutus", methods=['GET'])
#def about():
# return render_template('main/aboutus.html')
2018-01-29 11:29:35 -05:00
@main.route('/domaincheck', methods=['GET'])
def domaincheck():
return render_template('main/domaincheck.html')
2017-05-12 15:10:56 -04:00
@main.route("/terms", methods=['GET'])
def terms():
return render_template('main/terms.html')
2017-10-07 11:39:50 -04:00
#APP STORE
@main.route('/market/<int:group_id>', methods=['GET'])
@login_required
def market(group_id=0):
page = { 'title': 'Market' }
allproducts = Product.get_products()
allgroups = current_app.config['GROUPS']
if group_id == 0:
return render_template('main/market.html', groups=allgroups, products=allproducts)
filtered_products = {}
for key, value in allproducts.items():
if value['group'] == group_id:
filtered_products[key] = value
if filtered_products == {}:
abort(404)
return render_template('main/marketgroup.html', groupname=allgroups[group_id], products=filtered_products)