Пример #1
0
def create_app(object_name, env, dbcon):
    app = Flask(__name__)

    app.config.from_object(object_name)
    app.config['ENV'] = env
    app.config['SQLALCHEMY_DATABASE_URI'] = dbcon

    @app.errorhandler(500)
    def error_handler_500(e):
        if app.config['APP_SERVER'] != 'DEV':
            return render_template('500.html'), 500

    @app.errorhandler(404)
    def error_handler_404(e):
        if app.config['APP_SERVER'] != 'DEV':
            return render_template('404.html'), 404

    @app.route('/robots.txt')
    @app.route('/sitemap.xml')
    def static_from_root():
        return send_from_directory(app.static_folder, request.path[1:])

    @app.before_request
    def before_request():
        g.app_server = app.config['APP_SERVER']
        if 'db_engine' not in 'g':
            g.db_engine = create_engine(app.config['SQLALCHEMY_DATABASE_URI'])

    # register our blueprints
    from app.blueprints import main
    app.register_blueprint(main)

    return app
Пример #2
0
def create_app():
    app = Flask(__name__, static_folder='public')

    CsrfProtect(app)

    env = os.environ.get('TOGETHER_ENV', 'dev')
    app.config.from_object('together.settings.{}Config'.format(env.capitalize()))
    app.config['ENV'] = env

    from together.models import db, migrate, login_manager
    db.init_app(app)
    migrate.init_app(app, db)
    login_manager.init_app(app)

    from together.meta import meta
    app.register_blueprint(meta, url_prefix='/')

    from together.api import api, json_user
    api.init_app(app)

    app.context_processor(json_user)

    from together.assets import assets_env
    assets_env.init_app(app)

    return app
Пример #3
0
def create_app():
    app = Flask(__name__)

    # Determine current environment
    env = os.environ.get('APOLLO_ENV').capitalize() if os.environ.get('APOLLO_ENV') else 'Development'
    app.config.from_object('config.'+ env)
    app.config['ENV'] = env

    # Are we using postgres specific features?
    assert 'postgres' in app.config['SQLALCHEMY_DATABASE_URI']

    # Set up api routes
    from app.controllers import question
    app.register_blueprint(question)

    # Set up template routes
    @app.route("/")
    def index():
        values = {}
        questions = Question.query.filter(Question.is_live==True).all()
        values["questions"] = questions
        return render_template('index.html', **values)

    # Set up connection to DB
    db.init_app(app)
    return app
Пример #4
0
def create_app(object_name, env="prod"):
    app = Flask(__name__)

    app.config.from_object(object_name)
    app.config['ENV'] = env

    # define custom errors
    @app.errorhandler(400)
    def custom_error_400(error):
        response = jsonify({
            'code': 400,
            'message': 'Error 400 Bad request',
            'description': error.description,
        })
        response.status_code = 400
        return response

    @app.errorhandler(500)
    def custom_error_500(error):
        response = jsonify({
            'code': 500,
            'message': 'Error 500 Internal server error',
            'description': error.description,
        })
        response.status_code = 500
        return response

    # initialize SQLAlchemy
    db.init_app(app)

    # register our blueprints
    app.register_blueprint(main)

    return app
Пример #5
0
def create_app(object_name, env):
    """
    An flask application factory, as explained here:
    http://flask.pocoo.org/docs/patterns/appfactories/

    Arguments:
        object_name: the python path of the config object,
                     e.g. appname.settings.ProdConfig

        env: The name of the current environment, e.g. prod or dev
    """

    app = Flask(__name__)

    app.config.from_object(object_name)
    app.config['ENV'] = env

    # Initialize Jinja custom filters
    import filters
    filters.init_app(app)

    # register our blueprints
    from app.blueprints import main
    app.register_blueprint(main)
    
    @app.errorhandler(500)
    def error_handler_500(e):
        return render_template('500.html'), 500

    @app.errorhandler(404)
    def error_handler_404(e):
        return render_template('404.html'), 404

    return app
Пример #6
0
def create_app(object_name, env="prod"):
    """
    An flask application factory, as explained here:
    http://flask.pocoo.org/docs/patterns/appfactories/

    Arguments:
        object_name: the python path of the config object,
                     e.g. ark.settings.ProdConfig

        env: The name of the current environment, e.g. prod or dev
    """

    app = Flask(__name__)

    app.config.from_object(object_name)
    app.config['ENV'] = env

    # register tektonik
    tektonik.init_app(app)

    # register our blueprints
    app.register_blueprint(main_blueprint, url_prefix='/')
    app.register_blueprint(properties_blueprint, url_prefix='/properties')
    app.register_blueprint(paths_blueprint, url_prefix='/paths')
    app.register_blueprint(pages_blueprint, url_prefix='/pages')

    return app
Пример #7
0
def create_app(object_name, env="prod"):
    """
    An flask application factory, as explained here:
    http://flask.pocoo.org/docs/patterns/appfactories/

    Arguments:
        object_name: the python path of the config object,
                     e.g. appname.settings.ProdConfig

        env: The name of the current environment, e.g. prod or dev
    """

    app = Flask(__name__)

    app.config.from_object(object_name)
    app.config['ENV'] = env

    #init the cache
    cache.init_app(app)

    #init SQLAlchemy
    db.init_app(app)

    # Import and register the different asset bundles
    assets_env.init_app(app)
    assets_loader = PythonAssetsLoader(assets)
    for name, bundle in assets_loader.load_bundles().iteritems():
        assets_env.register(name, bundle)

    # register our blueprints
    from controllers.main import main
    app.register_blueprint(main)

    return app
Пример #8
0
def create_app(object_name, env="prod"):
    app = Flask(__name__)

    app.config.from_object(object_name)
    app.config['ENV'] = env
    db.init_app(app)
    mail.init_app(app)
    security = Security(app, user_datastore)

    @security.context_processor
    def security_context_processor():
        return dict(admin_base_template=admin.base_template,
                    admin_view=admin.index_view,
                    h=admin_helpers)

    admin.init_app(app)

    assets_env.init_app(app)
    assets_loader = PythonAssetsLoader(assets)
    for name, bundle in assets_loader.load_bundles().items():
        assets_env.register(name, bundle)

    with app.app_context():
        register_models()

    import pacioli.views.admin_views
    import pacioli.views.bookkeeping_views
    import pacioli.views.accounting_views
    import pacioli.views.ofx_views
    import pacioli.views.amazon_views
    import pacioli.views.payroll_views

    return app
Пример #9
0
def create_app(config, env="prod"):
  """
  Application factory
    config - the config object
    env - name of environment to load
  """

  app = Flask(__name__)

  app.config.from_object(config)
  app.config['ENV'] = env

  # Flask cache init
  cache.init_app(app)

  # Markdown
  md = Markdown(app)

  # initialize the debug tool bar
  debug_toolbar.init_app(app)

  # initialize SQLAlchemy
  db.init_app(app)

  login_manager.init_app(app)

  # register our blueprints
  app.register_blueprint(main)
  app.register_blueprint(user, url_prefix='/user')
  app.register_blueprint(api, url_prefix='/api')

  return app
Пример #10
0
def create_barebones_app(object_name, env):
    app = Flask(__name__)

    # set config
    app.config.from_object(object_name)
    app.config['ENV'] = env
    app.config['DEBUG'] = False if env=="prod" else True

    # register all custom jinja filters
    for f in jinja_filters:
        app.jinja_env.filters[f[0]] = f[1]

    #init the cache
    cache.init_app(app)

    #init SQLAlchemy
    db.init_app(app)

    #init celery 
    celery.config_from_object(app.config)

    #init Orthanc
    orthanc.init_app(app)

    #init logins
    lm.init_app(app)

    return app
Пример #11
0
def create_app(config_object, env):
    '''An application factory, as explained here:
        http://flask.pocoo.org/docs/patterns/appfactories/

    :param config_object: The configuration object to use.
    :param env: A string, the current environment. Either "dev" or "prod"
    '''
    app = Flask(__name__)
    app.config.from_object(config_object)
    app.config['ENV'] = env
    # Initialize SQLAlchemy
    db.init_app(app)
    # Register bcrypt
    bcrypt.init_app(app)
    # Register asset bundles
    assets_env.init_app(app)
    assets_loader = PythonLoader(assets)
    for name, bundle in assets_loader.load_bundles().iteritems():
        assets_env.register(name, bundle)
    # Register blueprints
    from flask_boilerplate.modules import public, member
    app.register_blueprint(public.blueprint)
    app.register_blueprint(member.blueprint)

    return app
Пример #12
0
def create_app(object_name, env):
    """
    An flask application factory, as explained here:
    http://flask.pocoo.org/docs/patterns/appfactories/

    Arguments:
        object_name: the python path of the config object,
                     e.g. appname.settings.ProdConfig

        env: The name of the current environment, e.g. prod or dev
    """

    app = Flask(__name__)

    app.config.from_object(object_name)
    app.config['ENV'] = env

    # Initialize socketio
    socketio.init_app(app)

    # register our blueprints
    from app.blueprints import main, tic_tac_toe, battleship, checkers, chess
    app.register_blueprint(main)
    app.register_blueprint(tic_tac_toe)
    app.register_blueprint(battleship)
    app.register_blueprint(checkers)
    app.register_blueprint(chess)

    return app
Пример #13
0
def create_app(config='dev'):
    """ Flask application factory
    :param str config: type of app to build, either "prod" or "dev"
    """
    # Create flask application
    app = Flask(__name__)
    app.config.from_object('settings')
    app.config['ENV'] = config
    app.jinja_env.trim_blocks = True

    # Debug toolbar (when debug=true)
    debug_toolbar = DebugToolbarExtension(app)
    app.config['DEBUG_TB_PROFILER_ENABLED'] = True
    app.config['DEBUG_TB_INTERCEPT_REDIRECTS'] = False

    # Register Blueprints
    app.register_blueprint(views_base.base)
    app.register_blueprint(views_blog.blog)

    # Flask-Assets; bundles all css/js files in minifed file
    assets = Environment(app)
    css_all = Bundle('css/bootstrap-flatly.min.css', 'css/highlightjs.min.css', 'css/font-awesome.css', 'css/main.css',
                     filters='cssmin', output='gen/style.css')
    js_all = Bundle('js/vendor/jquery.min.js', 'js/vendor/bootstrap.min.js', 'js/vendor/showdown-gfm.min.js',
                    'js/vendor/highlight.min.js', 'js/main.js', filters='jsmin', output='gen/libs.js')
    assets.register('css_all', css_all)
    assets.register('js_all', js_all)
    if app.config['DEBUG']:
        assets.debug = True
        app.config['ASSETS_DEBUG'] = True

    # Set up Flask-User
    babel = Babel(app)
    db_adapter = SQLAlchemyAdapter(db, User)
    user_manager = UserManager(db_adapter, app)  # Init Flask-User and bind to app

    # Init the cache
    cache.init_app(app)

    Moment(app)  # moment.js
    Misaka(app, autolink=True,  # Misaka Markdown
           fenced_code=True, lax_html=True, strikethrough=True,
           superscript=True, tables=True, wrap=True)

    # Init Admin page
    admin = Admin(app, index_view=AdminMain(endpoint='admin'))
    admin.add_view(PostAdminView())
    admin.add_view(NewPostView())
    admin.add_view(ModelView(Comment, db.session))
    static_path = os.path.join(BASE_DIR, 'app', 'static')
    admin.add_view(FileAdminView(static_path, '/static/', name='Static Files'))

    # Initialize DB
    db.init_app(app)

    return app
Пример #14
0
def create_app(object_name, env="development"):
    """
    An flask application factory, as explained here:
    http://flask.pocoo.org/docs/patterns/appfactories/

    Arguments:
        object_name: the python path of the config object,
                     e.g. appname.settings.ProdConfig

        env: The name of the current environment, e.g. prod or dev
    """

    app = Flask(__name__)

    app.config.from_object(object_name)
    app.config['ENV'] = env

    #init the cache
    cache.init_app(app)

    #init SQLAlchemy
    db.init_app(app)

    # Initialize Flask-Babel
    babel = Babel(app)                              
    
    # Initialize Flask-Mail
    mail = Mail(app)       

    # Initialize Flask-Migrate
    migrate = Migrate(app,db)
                         
    @babel.localeselector
    def get_locale():
        translations = [str(translation) for translation in babel.list_translations()]
        return request.accept_languages.best_match(translations)
    # Setup Flask-User
    db_adapter = SQLAlchemyAdapter(db,  Users)       # Select database adapter
    user_manager = UserManager(db_adapter, 
                               app,
                               register_form = IceRegisterForm)     # Init Flask-User and bind to app
    # register blueprints
    from controllers.main import main
    from controllers.customer import customer
    from controllers.email import email
    from controllers.schedule import schedule
    from controllers.kiosk import kiosk
    app.register_blueprint(main)
    app.register_blueprint(customer)
    app.register_blueprint(email)
    app.register_blueprint(schedule)
    app.register_blueprint(kiosk)

    return app
Пример #15
0
def create_app(object_name='stockpile.settings.DevConfig', env="dev"):
    app = Flask(__name__)

    app.config.from_object(object_name)
    app.config['ENV'] = env

    #init SQLAlchemy
    db.init_app(app)

    # register our blueprints
    from interface.main import mod as interfaceMod
    app.register_blueprint(interfaceMod)

    return app
Пример #16
0
def create_app(object_name, env='prod'):

    app = Flask(__name__)

    app.config.from_object(object_name)
    app.config['ENV'] = env

    app.register_blueprint(main_blueprint)

    assets = Environment(app)
    css = Bundle('css/style.scss', filters='scss', output='css/style.css')
    assets.register('base_style', css)

    return app
Пример #17
0
def create_app(object_name, env="prod"):
    """
    An flask application factory, as explained here:
    http://flask.pocoo.org/docs/patterns/appfactories/

    Arguments:
        object_name: the python path of the config object,
                     e.g. appname.settings.ProdConfig

        env: The name of the current environment, e.g. prod or dev
    """

    app = Flask(__name__)

    app.config.from_object(object_name)
    app.config['ENV'] = env

    # initialize the cache
    cache.init_app(app)

    # initialize the debug tool bar
    debug_toolbar.init_app(app)

    # initialize SQLAlchemy
    db.init_app(app)

    mail = Mail(app)

    security = Security(app, user_datastore)

    @security.context_processor
    def security_context_processor():
        return dict(
            admin_base_template=admin.base_template,
            admin_view=admin.index_view,
            h=admin_helpers,
        )

    admin.init_app(app)

    # Import and register the different asset bundles
    assets_env.init_app(app)
    assets_loader = PythonAssetsLoader(assets)
    for name, bundle in assets_loader.load_bundles().items():
        assets_env.register(name, bundle)

    # register our blueprints
    app.register_blueprint(main)

    return app
Пример #18
0
def create_app(object_name=None, env="dev", blueprints=None):

    app = Flask(__name__)

    app.config.from_object(object_name)
    app.config['ENV'] = env

    configure_extensions(app)
    configure_errorhandlers(app)
    configure_i18n(app)

    configure_blueprints(app)

    return app
Пример #19
0
def create_app(object_name, env="prod"):
    """
    An flask application factory, as explained here:
    http://flask.pocoo.org/docs/patterns/appfactories/

    Arguments:
        object_name: the python path of the config object,
                     e.g. appname.settings.ProdConfig

        env: The name of the current environment, e.g. prod or dev
    """
    app = Flask(__name__)

    app.config.from_object(object_name)

    upload_path = os.path.join(app.instance_path, app.config["SILVERFLASK_UPLOAD_FOLDER"])
    app.config["SILVERFLASK_ABSOLUTE_UPLOAD_PATH"] = upload_path
    app.storage_backend = LocalFileStorageBackend(upload_path)
    app.config['ENV'] = env

    db.init_app(app)
    logger.debug("DB Initialized")

    # init the cache
    cache.init_app(app)

    debug_toolbar.init_app(app)

    from silverflask.models import User
    user_adapter = SQLAlchemyAdapter(db, User)
    user_manager = UserManager(user_adapter, app)
    user_manager.enable_login_without_confirm_email = True

    # Import and register the different asset bundles
    assets_env.init_app(app)
    assets_loader = PythonAssetsLoader(assets)
    for name, bundle in list(assets_loader.load_bundles().items()):
        assets_env.register(name, bundle)

    # register our blueprints
    from silverflask.controllers.main import main
    from silverflask.controllers.main import setup_processors
    setup_processors(app)
    from silverflask.controllers.cms import bp as cms_bp
    app.register_blueprint(main)
    app.register_blueprint(cms_bp, url_prefix='/admin')

    with app.app_context():
        db.create_all()
    return app
Пример #20
0
def create_app(config_obj, env='prod'):
    """ A Flask application factory
            (http://flask.pocoo.org/docs/patterns/appfactories/)
    """
    app = Flask(__name__)

    app.config.from_object(config_obj)
    app.config['ENV'] = env

    db.init_app(app)

    # Register blueprints for the app.
    app.register_blueprint(main)

    return app
Пример #21
0
def create_app(object_name, env):
    """
    An flask application factory, as explained here:
    http://flask.pocoo.org/docs/patterns/appfactories/

    Arguments:
        object_name: the python path of the config object,
                     e.g. appname.settings.ProdConfig

        env: The name of the current environment, e.g. prod or dev
    """

    app = Flask(__name__)

    app.config.from_object(object_name)
    app.config['ENV'] = env

    #init SQLAlchemy
    db.init_app(app)
    db.Model = Base

    #Register Mail Service
    mail.init_app(app)

    # Initialize Jinja custom filters
    import filters
    filters.init_app(app)

    # Use Flask-Login to track current user in Flask's sessions
    login_manager.init_app(app)
    login_manager.login_view = 'auth.login'

    # register our blueprints
    from app.blueprints import main, auth, orgs, donors
    app.register_blueprint(main)
    app.register_blueprint(auth)
    app.register_blueprint(orgs)
    app.register_blueprint(donors)
    
    @app.errorhandler(500)
    def error_handler_500(e):
        return render_template('500.html'), 500

    @app.errorhandler(404)
    def error_handler_404(e):
        return render_template('404.html'), 404

    return app
Пример #22
0
def create_app(object_name, env="prod"):
    """
    An flask application factory, as explained here:
    http://flask.pocoo.org/docs/patterns/appfactories/

    Arguments:
        object_name: the python path of the config object,
                     e.g. appname.settings.ProdConfig

        env: The name of the current environment, e.g. prod or dev
    """

    app = Flask(__name__)

    app.config.from_object(object_name)
    app.config['ENV'] = env
    
    #init the cache
    cache.init_app(app)

    #init SQLAlchemy
    db.init_app(app)
    
    # connect to the database
    mongo.init_app(app)
    
    # init admin views
    import flask.ext.admin
    admin = flask.ext.admin.Admin(app, u'用户管理系统')
    babel = Babel(app)
    @babel.localeselector
    def get_locale():
        return 'zh'
    with app.app_context():
        admin.add_view(OperatorView(mongo.db.operator, u'专员管理'))

    # Import and register the different asset bundles
    assets_env.init_app(app)
    assets_loader = PythonAssetsLoader(assets)
    for name, bundle in assets_loader.load_bundles().iteritems():
        assets_env.register(name, bundle)

    # register our blueprints
    from controllers.main import main
    app.register_blueprint(main)

    return app
Пример #23
0
def create_app(object_name, env="prod"):
    """
    An flask application factory, as explained here:
    http://flask.pocoo.org/docs/patterns/appfactories/

    Arguments:
        object_name: the python path of the config object,
                     e.g. appname.settings.ProdConfig

        env: The name of the current environment, e.g. prod or dev
    """

    app = Flask(__name__)
    app.config.from_object(object_name)

    app.config['ENV'] = env

    return init_app(app)
Пример #24
0
def create_app(object_name, env="prod"):
    """
    An flask application factory, as explained here:
    http://flask.pocoo.org/docs/patterns/appfactories/

    Arguments:
        object_name: the python path of the config object,
                     e.g. fv_prov_es.settings.ProdConfig

        env: The name of the current environment, e.g. prod or dev
    """

    app = Flask(__name__)

    app.wsgi_app = ReverseProxied(app.wsgi_app)

    app.config.from_object(object_name)
    app.config['ENV'] = env

    #init extensions
    cache.init_app(app)
    debug_toolbar.init_app(app)
    db.init_app(app)
    login_manager.init_app(app)

    # Import and register the different asset bundles
    assets_env.init_app(app)
    assets_loader = PythonAssetsLoader(assets)
    for name, bundle in assets_loader.load_bundles().iteritems():
        assets_env.register(name, bundle)

    # register our blueprints
    from controllers.main import main
    app.register_blueprint(main)

    from controllers.services_v01 import services as services_v01
    app.register_blueprint(services_v01)

    from controllers.services_v02 import services as services_v02
    app.register_blueprint(services_v02)

    app.register_blueprint(apidoc.apidoc)

    return app
Пример #25
0
def create_app(config_object, env="prod"):
    app = Flask(__name__)

    app.config.from_object(config_object)
    app.config['ENV'] = env
    db.init_app(app)
    mail.init_app(app)
    security = Security(app, user_datastore)

    @security.context_processor
    def security_context_processor():
        return dict(admin_base_template=admin.base_template,
                    admin_view=admin.index_view,
                    h=admin_helpers,
                    get_url=url_for)

    admin.init_app(app)

    return app
Пример #26
0
def create_app(instance_path="", env="prod"):
    """Create the app."""
    app_name = '.'.join(__name__.split('.')[0:2])

    instance_path = instance_path or os.path.join(
        sys.prefix, 'var', app_name + '-instance'
    )
    try:
        if not os.path.exists(instance_path):
            os.makedirs(instance_path)
    except Exception:
        pass

    app = Flask(
        app_name,
        instance_path=instance_path,
        instance_relative_config=True,
        static_folder=os.path.join(instance_path, 'static'),
    )

    app.config['ENV'] = env
    env_object = "webfest.base.config.{0}Config".format(
        env.capitalize()
    )
    app.config.from_object(env_object)
    app.config.from_envvar('webfest_ENV_SRC', silent=True)
    app.config.from_pyfile('application.cfg', silent=True)

    # Ignore slashes
    app.url_map.strict_slashes = False

    # Add the proxies
    Registry(app=app)
    app.extensions['registry'].update(
        packages=PackageRegistry(app)
    )
    app.extensions['registry'].update(
        extensions=ExtensionRegistry(app),
        blueprints=BlueprintAutoDiscoveryRegistry(app=app),
    )
    ConfigurationRegistry(app)
    _setup_app_errors(app)
    return app
Пример #27
0
def create_app(object_name='bosphorus.settings', env='dev'):

    app = Flask(__name__)

    # set config
    app.config.from_object(object_name)
    app.config['ENV'] = env
    app.config['DEBUG'] = False if env=="prod" else True

    # register all custom jinja filters
    for f in jinja_filters:
        app.jinja_env.filters[f[0]] = f[1]

    #init the cache
    cache.init_app(app)

    #init SQLAlchemy
    db.init_app(app)

    #init Orthanc
    orthanc.init_app(app)

    # Import and register the different asset bundles
    assets_env = Environment()
    assets_env.init_app(app)
    assets_loader = PythonAssetsLoader(assets)
    for name, bundle in assets_loader.load_bundles().iteritems():
        assets_env.register(name, bundle)

    # register our blueprints
    from controllers.main import main
    from controllers.user import user
    from controllers.studies import studies
    from controllers.person import person
    from utils import proxy
    app.register_blueprint(main)
    app.register_blueprint(user)
    app.register_blueprint(person)
    app.register_blueprint(studies)
    app.register_blueprint(proxy)

    return app
Пример #28
0
def create_app(config=main_config, env=environment):
    if not config:
        raise ConfigNotFoundError('Config is not available')
    if not env:
        raise ConfigNotFoundError('Environment is not set')

    app = Flask(__name__,
                template_folder=os.path.abspath('templates'),
                static_folder=os.path.abspath('static'))
    
    app.config['DEBUG'] = flask_config.get('debug')
    app.config['ASSETS_DEBUG'] = app.config['DEBUG']

    app.config['SECRET_KEY'] = env['flask'].get('secret_key')
    app.config['ENV'] = env

    create_routes(app)
    compile_assets(app)

    return app
Пример #29
0
def setup_flask_app(manager_ip='localhost',
                    driver='',
                    hash_salt=None,
                    secret_key=None):
    """Setup a functioning flask app, when working outside the rest-service

    :param manager_ip: The IP of the manager
    :param driver: SQLA driver for postgres (e.g. pg8000)
    :param hash_salt: The salt to be used when creating user passwords
    :param secret_key: Secret key used when hashing flask tokens
    :return: A Flask app
    """
    app = Flask(__name__)
    db_uri = _get_postgres_db_uri(manager_ip, driver)
    app.config['SQLALCHEMY_DATABASE_URI'] = db_uri
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
    app.config['ENV'] = 'production'
    set_flask_security_config(app, hash_salt, secret_key)
    Security(app=app, datastore=user_datastore)
    Migrate(app=app, db=db)
    db.init_app(app)
    app.app_context().push()
    return app
Пример #30
0
def create_app(config=config, env=env):
    if not config:
        raise ConfigNotFoundError('Config is not available')
    if not env:
        raise ConfigNotFoundError('Environment is not set')

    tpl_folder = os.path.abspath('templates')
    static_folder = os.path.abspath('static')

    app = Flask(__name__,
                template_folder=tpl_folder,
                static_folder=static_folder,
                static_url_path='/s')
    
    app.config['DEBUG'] = env['flask'].get('debug')
    #if app.config['DEBUG'] is True:
    #    app.config['ASSETS_DEBUG'] = True

    app.config['SECRET_KEY'] = env['flask'].get('secret_key')
    app.config['ENV'] = env

    create_routes(app)

    return app