2016-04-10 21:23:27 +07:00
|
|
|
from werkzeug.contrib.fixers import ProxyFix
|
2016-08-05 16:20:41 +08:00
|
|
|
from flask import Flask, request, session, redirect, url_for
|
|
|
|
from flask_login import LoginManager
|
2018-06-12 14:00:21 -02:00
|
|
|
from flask_sqlalchemy import SQLAlchemy as SA
|
2018-06-11 10:58:47 +07:00
|
|
|
from flask_migrate import Migrate
|
2018-10-21 23:38:12 +01:00
|
|
|
from authlib.flask.client import OAuth as AuthlibOAuth
|
2018-08-20 17:21:32 +07:00
|
|
|
from sqlalchemy.exc import OperationalError
|
2018-11-21 10:24:33 +07:00
|
|
|
from flask_seasurf import SeaSurf
|
2018-06-12 14:00:21 -02:00
|
|
|
|
2019-01-23 12:00:26 +01:00
|
|
|
### SYBPATCH ###
|
|
|
|
from app.customboxes import customBoxes
|
|
|
|
### SYBPATCH ###
|
|
|
|
|
2018-06-12 14:00:21 -02:00
|
|
|
# subclass SQLAlchemy to enable pool_pre_ping
|
|
|
|
class SQLAlchemy(SA):
|
|
|
|
def apply_pool_defaults(self, app, options):
|
|
|
|
SA.apply_pool_defaults(self, app, options)
|
|
|
|
options["pool_pre_ping"] = True
|
|
|
|
|
2015-12-13 16:34:12 +07:00
|
|
|
|
2018-06-10 15:16:28 +02:00
|
|
|
from app.assets import assets
|
|
|
|
|
2015-12-13 16:34:12 +07:00
|
|
|
app = Flask(__name__)
|
|
|
|
app.config.from_object('config')
|
2016-04-10 21:23:27 +07:00
|
|
|
app.wsgi_app = ProxyFix(app.wsgi_app)
|
2018-11-21 10:24:33 +07:00
|
|
|
csrf = SeaSurf(app)
|
2016-04-10 21:23:27 +07:00
|
|
|
|
2018-06-10 15:16:28 +02:00
|
|
|
assets.init_app(app)
|
|
|
|
|
2018-04-12 11:18:44 +07:00
|
|
|
#### CONFIGURE LOGGER ####
|
|
|
|
from app.lib.log import logger
|
|
|
|
logging = logger('powerdns-admin', app.config['LOG_LEVEL'], app.config['LOG_FILE']).config()
|
|
|
|
|
2015-12-13 16:34:12 +07:00
|
|
|
login_manager = LoginManager()
|
|
|
|
login_manager.init_app(app)
|
2018-08-19 15:29:50 +07:00
|
|
|
db = SQLAlchemy(app) # database
|
|
|
|
migrate = Migrate(app, db) # flask-migrate
|
2018-10-21 23:38:12 +01:00
|
|
|
authlib_oauth_client = AuthlibOAuth(app) # authlib oauth
|
2018-01-20 17:17:02 +01:00
|
|
|
|
|
|
|
if app.config.get('SAML_ENABLED') and app.config.get('SAML_ENCRYPT'):
|
|
|
|
from app.lib import certutil
|
|
|
|
if not certutil.check_certificate():
|
|
|
|
certutil.create_self_signed_cert()
|
2018-08-19 15:29:50 +07:00
|
|
|
|
2018-08-20 17:21:32 +07:00
|
|
|
from app import models
|
2019-03-01 23:49:31 +01:00
|
|
|
|
|
|
|
from app.blueprints.api import api_blueprint
|
|
|
|
|
|
|
|
app.register_blueprint(api_blueprint, url_prefix='/api/v1')
|
|
|
|
|
2018-08-23 09:23:21 +07:00
|
|
|
from app import views
|