Esempio n. 1
0
def register_extensions(app):
    db.init_app(app)
    oauth.init_app(app)
    socketio.init_app(app)
    login_manager.init_app(app)
    csrf.init_app(app)
    moment.init_app(app)
Esempio n. 2
0
def configure_extensions(app):
    """ Configure app extension. """
    # flask SQLAlchemy
    db.init_app(app)
    db.create_all(app=app)

    # CSRF Protection
    csrf.init_app(app)

    @csrf.error_handler
    def csrf_error(reason):
        raise CsrfTokenError()

    # mail.init_app(app)

    # flask OAuthlib
    oauth.init_app(app)

    # Login Manger
    login_manager.init_app(app)

    #  Interface for anonymous users
    class AnonymousUserMixin(_AnonymousUserMixin):
        username = '******'
        firstName = ''
        lastName = ''
        email = ''
        role = Role.GUEST
        is_admin = False

    login_manager.login_view = 'auth.post_login'
    login_manager.session_protection = "strong"
    login_manager.anonymous_user = AnonymousUserMixin
Esempio n. 3
0
def create_app(config):
    app = Flask(__name__)
    app.config.from_object(config)
    db.init_app(app)
    # admin.init_app(app)
    login_manager.init_app(app)
    oauth.init_app(app)

    app.add_template_filter(date_filter, 'date')
    app.add_template_filter(null_filter, 'None_filter')
    app.add_template_filter(url_filter, 'url_filter')
    app.add_template_filter(page_filter, 'page_filter')
    app.add_template_filter(isdir, 'isdir')
    app.add_template_filter(relative_path, 'relative_path')

    from blog.main.views import main_blueprint
    app.register_blueprint(main_blueprint)

    from blog.admin.views import admin_blueprint
    app.register_blueprint(admin_blueprint)

    from blog.novel.views import novel_blueprint
    app.register_blueprint(novel_blueprint)

    from blog.cloudhub.views import cloud_hub_blueprint
    app.register_blueprint(cloud_hub_blueprint)

    from .main import views

    return app
Esempio n. 4
0
from apps.oauth.views import oauth_app

from app_exceptions import UserInputError

app = Flask(__name__)
app.config.from_object(os.environ.get('APP_CONFIG_CLASS'))


@app.errorhandler(UserInputError)
def handle_user_input_error(error):
    response = jsonify(error.to_dict())
    response.status_code = error.status_code
    return response


db.init_app(app)
db.app = app
oauth.init_app(app)
login_manager.init_app(app)
manager = Manager(app)
migrate = Migrate(app, db)

manager.add_command('db', MigrateCommand)

app.register_blueprint(index_app, url_prefix='/')
app.register_blueprint(user_app, url_prefix='/user')
app.register_blueprint(oauth_app, url_prefix='/oaut')

if __name__ == '__main__':
    manager.run()
Esempio n. 5
0
from apps.service.views import service_app
from apps.oauth.views import oauth_app

from app_exceptions import UserInputError

app = Flask(__name__)
app.config.from_object(os.environ.get('APP_CONFIG_CLASS'))

@app.errorhandler(UserInputError)
def handle_user_input_error(error):
    response = jsonify(error.to_dict())
    response.status_code = error.status_code
    return response


db.init_app(app)
db.app = app
oauth.init_app(app)
manager = Manager(app)
migrate = Migrate(app, db)

manager.add_command('db', MigrateCommand)

app.register_blueprint(index_app, url_prefix='/')
app.register_blueprint(service_app, url_prefix='/service')
app.register_blueprint(oauth_app, url_prefix='/oaut')


if __name__ == '__main__':
    manager.run()