コード例 #1
0
ファイル: __init__.py プロジェクト: sgenoud/federa
def create_app():
    # create and configure the app
    app = Flask(__name__, instance_relative_config=True)

    app.config.from_object(Configuration)
    app.config["PERMANENT_SESSION_LIFETIME"] = datetime.timedelta(days=4000)

    db.init_app(app.config.get("LOCAL_DYNAMODB"), prefix=app.config["TABLE_PREFIX"])

    CORS(app, supports_credentials=True)

    mastodon_bp = make_mastodon_blueprint(
        app.config["SERVICE_NAME"],
        scope="read",
        instance_credentials_backend=OAuthDynamoDbMemoryBackend(),
    )
    app.register_blueprint(mastodon_bp, url_prefix="/login")

    app.before_request(populate_actor_info)

    app.register_blueprint(site, url_prefix="/")
    app.register_blueprint(groupAPI, url_prefix="/api")
    app.register_blueprint(groupViews, url_prefix="/group")

    return app
コード例 #2
0
def create_app():

    app = Flask(__name__)
    app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite:///{}".format(
        os.path.join('instance', 'honey.db'))
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
    app.config['SECRET_KEY'] = 'rebornracekey'

    db.init_app(app)
    db.create_all(app=app)

    sio.init_app(app)

    app.register_blueprint(user.bp)
    app.register_blueprint(password.bp)
    app.register_blueprint(registration.bp)


    @app.after_request
    def after_request(response):
        response.headers.add('Access-Control-Allow-Origin', '*')
        response.headers.add('Access-Control-Allow-Headers', 'Content-Type,Authorization')
        response.headers.add('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS')
        return response

    return app
コード例 #3
0
ファイル: __init__.py プロジェクト: sgenoud/federa
def create_app():
    # create and configure the app
    app = Flask(__name__, instance_relative_config=True)

    app.config.from_object(Configuration)
    app.config["PERMANENT_SESSION_LIFETIME"] = datetime.timedelta(days=4000)

    db.init_app(app.config.get("LOCAL_DYNAMODB"), prefix=app.config["TABLE_PREFIX"])

    CORS(app, supports_credentials=True)

    mastodon_bp = make_mastodon_blueprint(
        app.config["SERVICE_NAME"],
        scope="read:accounts",
        instance_credentials_backend=OAuthDynamoDbMemoryBackend(),
    )
    app.register_blueprint(mastodon_bp, url_prefix="/login")

    app.before_request(populate_actor_info)

    app.register_blueprint(site, url_prefix="/")
    app.register_blueprint(groupAPI, url_prefix="/api")
    app.register_blueprint(groupViews, url_prefix="/group")

    return app
コード例 #4
0
def run():
    config = Configuration()

    db.init_app(config.LOCAL_DYNAMODB, prefix=config.TABLE_PREFIX, skip=True)

    table_name = db.engine._compute_table_name(GroupActivity)
    index = [g for g in GroupActivity.Meta.gsis if g.dynamo_name == "by_group"][0]

    table_changes = {
        "TableName": table_name,
        "AttributeDefinitions": attribute_definitions(GroupActivity),
        "GlobalSecondaryIndexUpdates": [
            {
                "Create": {
                    "IndexName": index.dynamo_name,
                    "KeySchema": key_schema(index=index),
                    "Projection": index_projection(index),
                    "ProvisionedThroughput": {
                        # On create when not specified, use minimum values instead of None
                        "WriteCapacityUnits": index.write_units or 1,
                        "ReadCapacityUnits": index.read_units or 1,
                    },
                }
            }
        ],
    }

    return db.engine.session.dynamodb_client.update_table(**table_changes)
コード例 #5
0
def init_db():
    '''
        Create tables necessary for this app to work.
    '''
    app = create_app()
    db.init_app( app )
    with app.test_request_context():
        db.create_all()
コード例 #6
0
def init_db():
    '''
        Create tables necessary for this app to work.
    '''
    app = create_app()
    db.init_app(app)
    with app.test_request_context():
        db.create_all()
コード例 #7
0
ファイル: __init__.py プロジェクト: weltenwort/dd4epinboard
def create_app():
    from server.views.frontend import frontend as blueprint_frontend
    from server.views.entry import entry as blueprint_entry
    from server.views.filter import filter as blueprint_filter
    from server.views.pinboard import pinboard as blueprint_pinboard
    from server.db import db
    from server.login import login_manager

    app = Flask(__name__, instance_relative_config=True)
    app.jinja_options = dict(app.jinja_options)
    app.jinja_env.add_extension('pyjade.ext.jinja.PyJadeExtension')

    app.config.from_pyfile("default_settings.py")
    app.config.from_envvar('PINBOARD_SETTINGS', silent=True)

    if not app.debug:
        file_handler = WatchedFileHandler(app.config.get("LOG_FILENAME",
            "pinboard.log"))
        file_handler.setLevel(logging.WARNING)
        app.logger.addHandler(file_handler)

    assets = Environment(app)

    js_assets = Bundle(
            "scripts/jquery-1.7.2.js",
            "scripts/jquery-ui-1.8.16.custom.min.js",
            #"scripts/chosen.jquery.min.js",
            "scripts/bootstrap.min.js",
            "scripts/angular-1.0.1.js",
            #"scripts/angular-cookies-1.0.0.js",
            #"scripts/taffy.js",
            "scripts/sugar-1.2.4.min.js",
            #"scripts/jquery.couch.js",
            Bundle("lib/*.coffee", filters=["coffeescript", ]),
            filters=["rjsmin", ],
            output="generated_app.js",
            )
    css_assets = Bundle(
            "stylesheets/jquery-ui-1.8.16.custom.css",
            Bundle(
                "stylesheets/app.less",
                filters=["less", ],
                ),
            filters=["cssmin", ],
            output="generated_app.css",
            )
    assets.register('js_all', js_assets)
    assets.register('css_all', css_assets)

    db.init_app(app)
    login_manager.setup_app(app)

    app.register_blueprint(blueprint_frontend)
    app.register_blueprint(blueprint_entry, url_prefix="/entry")
    app.register_blueprint(blueprint_filter, url_prefix="/filter")
    app.register_blueprint(blueprint_pinboard, url_prefix="/pinboards")

    return app
コード例 #8
0
def create_app(test_config=None):
    app = Flask(__name__)
    print("==========================FLASK ROOT_PATH======================")
    print(app.root_path)
    print("==========================FLASK ROOT_PATH======================")
    with app.app_context():
        db.init_app(app)

    register_routes(app)
    return app
コード例 #9
0
ファイル: __init__.py プロジェクト: a5huynh/flask-skeleton
def create_app( settings = 'server.settings.Dev' ):
    MAIN.config.from_object( settings )
    
    # Initialize db/cache with app
    db.init_app( MAIN )
    cache.init_app( MAIN )
    
    # Register apis
    MAIN.register_blueprint( test_api, url_prefix='/test' )
        
    return MAIN
コード例 #10
0
def create_app():
    app = Flask(__name__)
    app.config['SQLALCHEMY_DATABASE_URI'] = DATABASE_URI
    app.config['SERVER_NAME'] = SERVER_NAME
    app.config['DEBUG'] = FLASK_DEBUG

    register_blueprints(app)

    db.init_app(app)
    init_logging(app)

    return app
コード例 #11
0
def create_app(settings='server.settings.Dev'):
    MAIN.config.from_object(settings)

    # Initialize db/cache with app
    db.init_app(MAIN)
    cache.init_app(MAIN)

    # Register apis
    MAIN.register_blueprint(analyzer_api, url_prefix='/api')
    MAIN.register_blueprint(misc_api, url_prefix='/api')

    return MAIN
コード例 #12
0
ファイル: app.py プロジェクト: mschmo/pbubs
def create_app():
    app = Flask(__name__)
    app.config.from_pyfile('config_default.py')
    app.config.from_pyfile('config_local.py', silent=True)
    Migrate(app, db)
    configure_oauth(app)
    db.init_app(app)

    login_manager.init_app(app)
    app.register_blueprint(auth_bp)
    app.register_blueprint(bills)
    app.register_blueprint(core)

    return app
コード例 #13
0
def create_app():
    # create and configure the app
    app = Flask(__name__, instance_relative_config=True)
    app.config.from_object(Configuration)

    db.init_app(app.config.get("LOCAL_DYNAMODB"), prefix=app.config["TABLE_PREFIX"])

    CORS(app, supports_credentials=True)

    webfingerAPI = make_webfinger_blueprint()
    app.register_blueprint(group.blueprint, url_prefix="/")
    webfingerAPI.register_actor(group)

    app.register_blueprint(webfingerAPI, url_prefix="/.well-known")

    return app
コード例 #14
0
ファイル: __init__.py プロジェクト: amaradatta93/IssueLog
def create_app(test_config=None):
    # create and configure the app
    app = Flask(__name__, instance_relative_config=True)

    app.config.from_mapping(SECRET_KEY='dev',
                            UPLOAD_FOLDER=UPLOAD_FOLDER,
                            SQLALCHEMY_TRACK_MODIFICATIONS=False)
    app.config.update(MAIL_USERNAME=mail_username,
                      MAIL_PASSWORD=mail_password,
                      MAIL_SERVER=mail_server,
                      MAIL_PORT=mail_port,
                      MAIL_USE_SSL=mail_use_ssl,
                      SQLALCHEMY_DATABASE_URI=
                      f'mysql://{username}:{password}@{host}/{db_name}')

    CORS(app, resources={r"/*": {"origins": "localhost:4200"}})
    JWTManager(app)
    mail = Mail()

    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.from_mapping(test_config)

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

    db.init_app(app)
    migrate = Migrate(app, db)

    mail.init_app(app)

    from . import auth
    app.register_blueprint(auth.bp)

    from . import views
    app.register_blueprint(views.dashboard)
    app.register_blueprint(views.support_engineers)

    return app
コード例 #15
0
ファイル: main.py プロジェクト: ptouati/banner-creator
def create_app():
    app = Flask(__name__, instance_relative_config=True)

    setup_routes(app)

    # apply default config and dev config from instance/config.py if exists
    app.config.from_object('server.config.default')
    app.config.from_pyfile('config.py', silent=True)
    # apply config from env variable, must be an absolute path to python file
    app.config.from_envvar('APP_CONFIG_FILE')

    # i18n
    Babel(app)

    # add custom jinja2 filters
    init_custom_filters(app)

    db.init_app(app)

    # auth init
    login_manager = LoginManager(app)
    login_manager.login_view = "login_page"
    login_manager.login_message = None
    login_manager.user_loader(load_user)

    CsrfProtect(app)

    # load all models to be available for db migration tool
    from server import models

    migrate = Migrate(app, db, directory='server/migrations')

    # logging config
    app.logger.handlers.clear()  # remove default loggers
    handler = logging.StreamHandler(stream=sys.stdout)
    handler.setLevel(app.config['LOGGING_LEVEL'])
    formatter = logging.Formatter(app.config['LOGGING_FORMAT'])
    handler.setFormatter(formatter)
    app.logger.addHandler(handler)

    return app
コード例 #16
0
ファイル: index.py プロジェクト: phinguyen712/IndeedLite
def create_tables():
    db.create_all()

jwt = JWT(app, authenticate, identity)  # /auth


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


# stop browser from caching static bundle.js file // this is for dev env only.
@app.after_request
def add_header(r):

    r.headers["Cache-Control"] = "no-cache, no-store, must-revalidate"
    r.headers["Pragma"] = "no-cache"
    r.headers["Expires"] = "0"
    r.headers['Cache-Control'] = 'public, max-age=0'
    return r


api.add_resource(UserRegister, '/register')
api.add_resource(Search, '/search')


if __name__ == '__main__':
    from server.db import db
    db.init_app(app)
    app.run(port=5000, debug=True)
コード例 #17
0
def register_plugins(app):
    CORS(app)
    db.init_app(app)
    ma.init_app(app)