Пример #1
0
def create_app():
    app = CustomFlask(__name__)
    config = os.environ.get('CONFIG', 'config.DevConfig')
    app.config.from_object(config)
    db.init_app(app)
    Migrate(app, db)
    return app
Пример #2
0
def create_app():
    app = Flask(__name__)
    app.config.from_object('settings')
    route_app(app)
    register_assets(app)
    db.init_app(app)
    return app
Пример #3
0
def create_app():
    app = Flask(__name__)
    app.config.from_object('settings')
    route_app(app)
    register_assets(app)
    db.init_app(app)
    return app
Пример #4
0
def create_app():
    app = Flask(__name__)
    app.config["SQLALCHEMY_DATABASE_URI"] = "postgresql://*****:*****@127.0.0.1:15432"
    db.init_app(app)
    migrate = Migrate(app,db)

    app.register_blueprint(api)

    return app
Пример #5
0
def create_app():
    app = Flask(__name__)
    app.config[
        "SQLALCHEMY_DATABASE_URI"] = "postgresql://*****:*****@127.0.0.1:15432"
    db.init_app(app)
    migrate = Migrate(app, db)

    app.register_blueprint(api)

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

    load_config(app, cfg)

    # SQLAlchemy
    db.init_app(app)

    user_datastore = SQLAlchemyUserDatastore(db, User, Role)
    security.init_app(app, user_datastore)

    media_file_api.init_defaults(db, app.config['UPLOAD_FOLDER'],
                                 app.config['ALLOWED_EXTENSIONS'])
    process_api.init_defaults(db)
    transcription_api.init_defaults(db, app.config['UPLOAD_FOLDER'])
    correction_api.init_defaults(db)

    babel = Babel()
    babel.init_app(app)

    compress = Compress()
    compress.init_app(app)

    from api.views.internal_views import api as api_internal_views
    from api.views.asr_model_views import api as api_asr_model_views
    from api.views.process_views import api as api_process_views
    from api.views.correction_views import api as api_correction_views
    from api.views.files_views import api as api_files_views
    from api.views.all_views import api as api_all_views
    from api.blueprint import api
    from frontend.views import frontend

    app.register_blueprint(api, url_prefix='/api')
    app.register_blueprint(api, url_prefix='/api/<version>')
    app.register_blueprint(frontend)

    configure_filters(app)

    @app.errorhandler(404)
    def not_found(error):
        return make_response(jsonify({'error': 'Not found'}), 404)

    @app.errorhandler(400)
    def not_found(error):
        return make_response(jsonify({'error': 'Bad request'}), 400)

    return app
Пример #7
0
def create_app(config_object):

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

    for blueprint in futurepress_blueprints:
        app.register_blueprint(blueprint)

    db = SQLAlchemy()
    db.init_app(app)

    stormpath_manager = StormpathManager(app)
    stormpath_manager.login_view = 'auth_routes.login'

    @app.context_processor
    def inject_appuser():
        if user.is_authenticated():
            user_id = user.get_id()
            app_user = AppUser.query.get(stormpathUserHash(user_id))
            return dict(app_user=app_user)
        return dict(app_user=None)

    @app.route('/')
    def index():
        return render_template('index.html')

    @app.route('/copyright')
    def copyright():
        return render_template('copyright.html')

    @app.route('/makers')
    def makers():
        """ """
        if user.is_authenticated():
            return render_template('makers.html')

        return render_template('makers.html')

    @app.route('/readers')
    def readers():
        if user.is_authenticated():
            return render_template('readers.html')

        return render_template('readers.html')

    return app
Пример #8
0
def create_app(app_name,config_obj):
    """
    Create the flask application
    """
    # Initialize app object
    app = Flask(app_name)
    # Configure app object
    app.config.from_object(config_obj)
    # Initialize database
    db.init_app(app)
    app.db = db

    # Initialize Api
    api.app = app
    api.init_app(app)
    app.api = api
    return app
Пример #9
0
def create_app(app_name, config_obj):
    """
    Create the flask application
    """
    # Initialize app object
    app = Flask(app_name)
    # Configure app object
    app.config.from_object(config_obj)
    # Initialize database
    db.init_app(app)
    app.db = db

    # Initialize Api
    api.app = app
    api.init_app(app)
    app.api = api
    return app
Пример #10
0
def create_app(package_name, package_path, settings_override=None,
               register_security_blueprint=True):
    """Returns a :class:`Flask` application instance configured with common
    functionality for the Application platform.

    :param package_name: application package name
    :param package_path: application package path
    :param settings_override: a dictionary of settings to override
    :param register_security_blueprint: flag to specify if the Flask-Security
                                        Blueprint should be registered. Defaults
                                        to `True`.
    """

    app = Flask(package_name, instance_relative_config=True, static_url_path='/static/'+str(STATIC_GUID))
    app.config.from_object('application.settings')
    app.config.from_pyfile('settings.cfg', silent=True)
    app.config.from_object(settings_override)
    db.app = app
    db.init_app(app)
    mail.init_app(app)
    babel.init_app(app)
    # Init cache
    cache.init_app(app)
    # Init Sentry
    sentry.init_app(app)
    # cache.init_app(app, config={'CACHE_TYPE': 'simple'})
    user_datastore = SQLAlchemyUserDatastore(db, User, Role)
    security.datastore = user_datastore
    security.init_app(app, user_datastore,
                      register_blueprint=register_security_blueprint)
    social.init_app(app, SQLAlchemyConnectionDatastore(db, Connection))
    #gravatar.__init__(app, size=128, rating='g', default='mm', force_default=False,
    #                  force_lower=False, use_ssl=False)
    register_blueprints(app, package_name, package_path)
    app.wsgi_app = ProxyFix(HTTPMethodOverrideMiddleware(app.wsgi_app))

    if not app.debug:
        import logging
        from logging.handlers import RotatingFileHandler
        file_handler = RotatingFileHandler('logs/errors_debug.log', maxBytes=1024 * 1024 * 100, backupCount=20)
        file_handler.setLevel(logging.WARNING)
        formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
        file_handler.setFormatter(formatter)
        app.logger.addHandler(file_handler)

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

    app.config.from_object('config')

    db.init_app(app)
    oauth.init_app(app)
    oauth._validator = RequestValidator()

    app.register_blueprint(myapi, url_prefix=url_prefix)
    app.register_blueprint(todos_api, url_prefix=url_prefix)
    app.register_blueprint(users_api, url_prefix=url_prefix)
    app.register_blueprint(posts_api, url_prefix=url_prefix)
    app.register_blueprint(photos_api, url_prefix=url_prefix)
    app.register_blueprint(comments_api, url_prefix=url_prefix)
    app.register_blueprint(albums_api, url_prefix=url_prefix)

    return app
Пример #12
0
def create_app():
    """Construct the core application."""
    app = Flask(__name__, instance_relative_config=False)
    CORS(app)
    app.config["SQLALCHEMY_DATABASE_URI"] = DB_URL
    app.config[
        "SQLALCHEMY_TRACK_MODIFICATIONS"] = False  # silence the deprecation warning

    app.secret_key = getenv("FLASK_SECRET_KEY")

    db.init_app(app)

    from settings import board_bp

    app.register_blueprint(board_bp, url_prefix=URL_PREFIX)

    with app.app_context():
        db.create_all()

        return app
Пример #13
0
def create_app(settings_override=None):
    """ Method for creating and initializing application.

        :param settings_override: Dictionary of settings to override.
    """
    app = Flask(__name__)

    # Update configuration.
    app.config.from_object('settings')
    app.config.from_pyfile('settings.cfg', silent=True)
    app.config.from_object(settings_override)

    # Initialize extensions on the application.
    db.init_app(app)
    oauth.init_app(app)
    oauth._validator = MyRequestValidator()

    # Register views on the application.
    app.register_blueprint(yoloapi)

    return app
Пример #14
0
def make_app(**kwargs):
    import socket
    socket.setdefaulttimeout(kwargs.get('timeout', 2))
    if kwargs:
        config.DEBUG = kwargs.get('debug')
        config.DOC = kwargs.get('doc')
        config.PORT = kwargs.get('port')
        config.WORKER = kwargs.get('worker')

    url_list = []
    url_list.extend(config.URIS)

    app_settings = {
        "cookie_secret": "bZJc2sWbQLKos6GkHn/VB9oXwQt8S0R0kRvJ5/xJ89E=",
        "static_path": os.path.join(os.path.dirname(__file__), "static")
    }

    app = Application(url_list, __name__, debug=config.DEBUG, **app_settings)

    db.init_app(app)
    db.app = app
    migrate.init_app(app, db)
    return app
Пример #15
0
def create_app(test_config=None):
    """Create and configure an instance of the Flask application."""

    dir_path = os.path.dirname(os.path.realpath(__file__))
    print(dir_path)
    UPLOAD_FOLDER = os.path.join(dir_path, "uploads")
    DOWNLOAD_FOLDER = os.path.join(dir_path, "downloads")

    app = Flask(__name__, instance_relative_config=True)
    dropzone.init_app(app)
    app.config["UPLOAD_FOLDER"] = UPLOAD_FOLDER
    app.config["DOWNLOAD_FOLDER"] = DOWNLOAD_FOLDER
    app.config["MAX_CONTENT_LENGTH"] = 8 * 1024 * 1024
    app.config.update(
        DROPZONE_MAX_FILE_SIZE=3,
        DROPZONE_MAX_FILES=30,
        DROPZONE_PARALLEL_UPLOADS=3,  # set parallel amount
        DROPZONE_UPLOAD_MULTIPLE=True,
        DROPZONE_UPLOAD_ON_CLICK=True,
        DROPZONE_ALLOWED_FILE_CUSTOM=False,
        # DROPZONE_REDIRECT_VIEW = 'merge.uploaded_file'  # set redirect view
    )

    app.config.from_mapping(
        # a default secret that should be overridden by instance config
        SECRET_KEY="dev",
        # store the database in the instance folder
        DATABASE=os.path.join(app.instance_path, "flaskr.sqlite"),
    )

    if test_config is None:
        # load the instance config, if it exists, when not testing
        app.config.from_pyfile("config.py", silent=True)
    else:
        # load the test config if passed in
        app.config.update(test_config)

    # ensure the instance folder exists
    try:
        os.makedirs(app.instance_path)
    except OSError:
        pass

    # register the database commands
    from core import db

    db.init_app(app)

    # apply the blueprints to the app
    from core import merge, youtube, index, conv, rotate

    app.register_blueprint(youtube.bp)
    app.register_blueprint(merge.bp)
    app.register_blueprint(index.bp)
    app.register_blueprint(conv.bp)
    app.register_blueprint(rotate.bp)
    # make url_for('index') == url_for('blog.index')
    # in another app, you might define a separate main index here with
    # app.route, while giving the blog blueprint a url_prefix, but for
    # the tutorial the blog will be the main index
    app.add_url_rule("/", endpoint="index")

    return app
Пример #16
0
                                User,
                                login_required,
                                login_user,
                                logout_user,
                                user,
                            )

from stormpath.error import Error as StormpathError
from settings import basedir

from futurepress import futurepress_blueprints
from models import ( AppUser, stormpathUserHash )
from core import db, DevConfig

app = Flask(__name__)
db.init_app(app)

migrate = Migrate(app, db)

manager = Manager(app)
manager.add_command('db', MigrateCommand)

def create_app(config_object):

    app.config.from_object(config_object)

    for blueprint in futurepress_blueprints:
        app.register_blueprint(blueprint)

    @app.context_processor
    def inject_appuser():
Пример #17
0
def init_extensions(app):
    db.init_app(app)