diff --git a/app/__init__.py b/app/__init__.py index a218925..430c794 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -1,4 +1,5 @@ from flask import Flask, g, render_template, request +from flask.json import JSONEncoder from flask_bootstrap import Bootstrap from flask_mail import Mail from flask_sqlalchemy import SQLAlchemy @@ -6,9 +7,11 @@ from flask_login import LoginManager from flask_wtf.csrf import CSRFProtect, CSRFError from flask_babel import Babel, lazy_gettext from werkzeug.contrib.fixers import ProxyFix +from config import config app = Flask(__name__) -app.config.from_object('config') +app.config.from_object(config['default']) +config['default'].init_app(app) app.wsgi_app = ProxyFix(app.wsgi_app) db = SQLAlchemy(session_options = { "autoflush": False }) @@ -19,17 +22,14 @@ lm.login_view = 'auth.login' lm.login_message = 'Login Required.' lm.session_protection = 'strong' #lm.session_protection = 'basic' -mail = Mail(app) -bootstrap = Bootstrap(app) -#csrf = CSRFProtect(app) -babel = Babel(app) - -#bootstrap.init_app(app) -#mail.init_app(app) -#db.init_app(app) -#lm.init_app(app) -#babel.init_app(app) -#csrf.init_app(app) +mail = Mail() +mail.init_app(app) +bootstrap = Bootstrap() +bootstrap.init_app(app) +csrf = CSRFProtect() +csrf.init_app(app) +babel = Babel() +babel.init_app(app) from .vmanager import vmanager as vmanager_blueprint app.register_blueprint(vmanager_blueprint) @@ -109,7 +109,7 @@ if not app.debug and app.config['MAIL_SERVER'] != '': import logging from logging.handlers import SMTPHandler credentials = None - secure = Nonep + secure = None if app.config['MAIL_USERNAME'] or app.config['MAIL_PASSWORD']: credentials = (app.config['MAIL_USERNAME'], app.config['MAIL_PASSWORD']) if app.config['MAIL_USE_TLS'] is None: diff --git a/app/models.py b/app/models.py index 84784b2..7e720f5 100644 --- a/app/models.py +++ b/app/models.py @@ -4,7 +4,7 @@ from itsdangerous import TimedJSONWebSignatureSerializer as Serializer from flask import current_app, request, url_for from flask_login import UserMixin, AnonymousUserMixin -from proxadmin.exceptions import ValidationError +from app.exceptions import ValidationError from . import db, lm import os diff --git a/manage.py b/manage.py index 726027b..164188e 100644 --- a/manage.py +++ b/manage.py @@ -2,7 +2,7 @@ import os import subprocess, shlex -from proxadmin import app, db +from app import app, db from flask_script import Manager, Shell, Command from flask_migrate import Migrate, MigrateCommand diff --git a/run.py b/run.py index 24dbfec..3a43937 100644 --- a/run.py +++ b/run.py @@ -1,4 +1,4 @@ -from proxadmin import app +from app import app if __name__ == '__main__': app.run()