Beispiel #1
0
def create_app(config=None):

    app = Flask(__name__)

    # If no config file is passed in on the command line:
    if config is None:
        #config = os.path.join(app.root_path, os.environ.get('FLASK_APPLICATION_SETTINGS'))
        config = os.path.join(os.path.dirname( __file__ ), "../config/", "config.cfg")

    app.config.from_pyfile(config)

    # Secret key needed to use sessions.
    app.secret_key = app.config['SECRET_KEY']

    app.mail = Mail(app)

    # Initialize SQL Alchemy and Flask-Login
    # Instantiate the Bcrypt extension
    db.init_app(app)
    if (app.config['CREATE_SCHEMA']):
        with app.app_context():
            db.create_all()
    login_manager.init_app(app)
    bcrypt.init_app(app)

    # CSRF protection
    csrf.init_app(app)

    # Web assets (js, less)
    assets = Environment(app)
    js = Bundle('js/main.js',
                filters='jsmin', output='gen/bundle.js')
    assets.register('js_all', js)

    # Automatically tear down SQLAlchemy
    @app.teardown_request
    def shutdown_session(exception=None):
        db.session.remove()

    @app.before_request
    def before_request():
        g.user = current_user

    app.register_blueprint(unauthenticated)
    app.register_blueprint(authenticated)
    app.register_blueprint(users)

    return app
Beispiel #2
0
def create_app(config=None):

    app = Flask(__name__)


    # If no config file is passed in on the command line:
    # if config is None:
    #     config = os.path.join(app.root_path, os.environ.get('FLASK_APPLICATION_SETTINGS'))

    # app.config.from_pyfile(config)

    # Secret key needed to use sessions.
    app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/easytransfer.db'
    app.config['SECRET_KEY'] = 'gi3mHUx8hcLoQrnqP1XOkSORrjxZVkST'

    app.secret_key = app.config['SECRET_KEY']

    # Initialize SQL Alchemy and Flask-Login
    # Instantiate the Bcrypt extension
    db.init_app(app)
    login_manager.init_app(app)
    bcrypt.init_app(app)

    # CSRF protection
    # csrf.init_app(app)

    # Web assets (js, less)
    assets = Environment(app)
    js = Bundle('js/main.js',
                filters='jsmin', output='gen/bundle.js')
    assets.register('js_all', js)

    # Automatically tear down SQLAlchemy
    @app.teardown_request
    def shutdown_session(exception=None):
        db.session.remove()

    @app.before_request
    def before_request():
        g.user = current_user

    app.register_blueprint(unauthenticated)
    app.register_blueprint(authenticated)
    app.register_blueprint(users)

    return app
def create_app(config=None):

    app = Flask(__name__)


    # If no config file is passed in on the command line:
    if config is None:
        config = os.path.join(app.root_path, os.environ.get('FLASK_APPLICATION_SETTINGS'))

    app.config.from_pyfile(config)

    # Secret key needed to use sessions.
    app.secret_key = app.config['SECRET_KEY']

    # Initialize SQL Alchemy and Flask-Login
    # Instantiate the Bcrypt extension
    db.init_app(app)
    login_manager.init_app(app)
    bcrypt.init_app(app)

    # CSRF protection
    csrf.init_app(app)

    # Web assets (js, less)
    assets = Environment(app)
    js = Bundle('js/main.js',
                filters='jsmin', output='gen/bundle.js')
    assets.register('js_all', js)

    # Automatically tear down SQLAlchemy
    @app.teardown_request
    def shutdown_session(exception=None):
        db.session.remove()

    @app.before_request
    def before_request():
        g.user = current_user

    app.register_blueprint(unauthenticated)
    app.register_blueprint(authenticated)
    app.register_blueprint(users)

    return app
Beispiel #4
0
def create_app(config=None):

    app = Flask(__name__)

    # If no config file is passed in on the command line:
    if config is None:
        config = os.path.join(app.root_path, os.environ.get("FLASK_APPLICATION_SETTINGS"))

    app.config.from_pyfile(config)

    # Secret key needed to use sessions.
    app.secret_key = app.config["SECRET_KEY"]

    # Initialize SQL Alchemy and Flask-Login
    # Instantiate the Bcrypt extension
    db.init_app(app)
    login_manager.init_app(app)
    bcrypt.init_app(app)

    # CSRF protection
    csrf.init_app(app)

    # Web assets (js, less)
    assets = Environment(app)
    js = Bundle("js/main.js", filters="jsmin", output="gen/bundle.js")
    assets.register("js_all", js)

    # Automatically tear down SQLAlchemy
    @app.teardown_request
    def shutdown_session(exception=None):
        db.session.remove()

    @app.before_request
    def before_request():
        g.user = current_user

    app.register_blueprint(unauthenticated)
    app.register_blueprint(authenticated)
    app.register_blueprint(users)
    # app.register_blueprint(upload)
    return app