def create_app(): app.config.from_object(os.environ.get('APP_CONFIG', 'config.ProductionConfig')) app.logger.addHandler(logging.StreamHandler(sys.stdout)) app.logger.setLevel(logging.ERROR) app.jinja_env.add_extension('jinja2.ext.do') app.jinja_env.add_extension('jinja2.ext.loopcontrols') app.jinja_env.undefined = SilentUndefined # Make sure the working directory exists. If not create it. if not os.path.exists(app.config['WORKING_DIR']): os.makedirs(app.config['WORKING_DIR']) # Make sure the upload directory exists. If not create it. if not os.path.exists(app.config['UPLOAD_DIR']): os.makedirs(app.config['UPLOAD_DIR']) # Make sure the directory is writable if not os.access(app.config['WORKING_DIR'], os.W_OK): print("The working directory " + app.config['WORKING_DIR'] + " is not writable. Cannot start worker.") exit() HTMLMIN(app) app.register_blueprint(views) app.register_blueprint(api) return app
def create_app(): babel.init_app(app) BlueprintsManager.register(app) Migrate(app, db) app.config.from_object(environ.get('APP_CONFIG', 'config.ProductionConfig')) db.init_app(app) _manager = Manager(app) _manager.add_command('db', MigrateCommand) if app.config['CACHING']: cache.init_app(app, config={'CACHE_TYPE': 'simple'}) else: cache.init_app(app, config={'CACHE_TYPE': 'null'}) stripe.api_key = 'SomeStripeKey' app.secret_key = 'super secret key' app.json_encoder = MiniJSONEncoder app.config['BABEL_DEFAULT_LOCALE'] = 'en' app.config['JSONIFY_PRETTYPRINT_REGULAR'] = False app.config['FILE_SYSTEM_STORAGE_FILE_VIEW'] = 'static' app.logger.addHandler(logging.StreamHandler(sys.stdout)) app.logger.setLevel(logging.ERROR) app.jinja_env.add_extension('jinja2.ext.do') app.jinja_env.add_extension('jinja2.ext.loopcontrols') app.jinja_env.undefined = SilentUndefined app.jinja_env.filters['operation_name'] = operation_name # set up jwt app.config['JWT_AUTH_USERNAME_KEY'] = 'email' app.config['JWT_EXPIRATION_DELTA'] = timedelta(seconds=24 * 60 * 60) app.config['JWT_AUTH_URL_RULE'] = None _jwt = JWT(app, jwt_authenticate, jwt_identity) # setup celery app.config['CELERY_BROKER_URL'] = environ.get('REDIS_URL', 'redis://localhost:6379/0') app.config['CELERY_RESULT_BACKEND'] = app.config['CELERY_BROKER_URL'] HTMLMIN(app) CORS(app, resources={r"/api/*": {"origins": "*"}}) AuthManager.init_login(app) if app.config['TESTING'] and app.config['PROFILE']: # Profiling app.wsgi_app = ProfilerMiddleware(app.wsgi_app, restrictions=[30]) # API version 2 with app.app_context(): from app.api import api_v1 app.register_blueprint(api_v1) sa.orm.configure_mappers() return app, _manager, db, _jwt
def register_extensions(app): db_config = { 'host': app.config.get('USER_DB_HOST', ''), 'name': app.config.get('USER_DB_NAME', ''), 'user': app.config.get('USER_DB_USER', ''), 'password': app.config.get('USER_DB_PASSWORD', ''), } Database.connect(**db_config) cache_bust.init_cache_busting(app) Compress(app) HTMLMIN(app)
def create_app(): auto = Autodoc(app) cal = Calendar() event = Event() app.register_blueprint(api_v1_routes) migrate = Migrate(app, db) app.config.from_object(environ.get('APP_CONFIG', 'config.ProductionConfig')) db.init_app(app) manager = Manager(app) manager.add_command('db', MigrateCommand) cors = CORS(app) app.secret_key = 'super secret key' app.config['UPLOADS_FOLDER'] = os.path.realpath('.') + '/static/' app.config['FILE_SYSTEM_STORAGE_FILE_VIEW'] = 'static' app.config['STATIC_URL'] = '/static/' app.config['STATIC_ROOT'] = 'staticfiles' app.config['STATICFILES_DIRS'] = (os.path.join(BASE_DIR, 'static'), ) app.config['SQLALCHEMY_RECORD_QUERIES'] = True app.logger.addHandler(logging.StreamHandler(sys.stdout)) app.logger.setLevel(logging.INFO) app.jinja_env.add_extension('jinja2.ext.do') app.jinja_env.add_extension('jinja2.ext.loopcontrols') app.jinja_env.undefined = SilentUndefined app.jinja_env.filters['operation_name'] = operation_name # logging.getLogger('sqlalchemy.engine').setLevel(logging.INFO) # set up jwt app.config['JWT_AUTH_USERNAME_KEY'] = 'email' app.config['JWT_EXPIRATION_DELTA'] = timedelta(seconds=24 * 60 * 60) app.config['JWT_AUTH_URL_RULE'] = None jwt = JWT(app, jwt_authenticate, jwt_identity) HTMLMIN(app) admin_view = AdminView("Open Event") admin_view.init(app) admin_view.init_login(app) # API version 2 with app.app_context(): from open_event.api import api_v2 app.register_blueprint(api_v2) sa.orm.configure_mappers() return app, manager, db, jwt
"""Instances of modules used to compress transfers.""" from flask_compress import Compress from flask.ext.htmlmin import HTMLMIN compress = Compress() htmlmin = HTMLMIN()
def create_app(): Autodoc(app) # cal = Calendar() babel.init_app(app) app.register_blueprint(babel_routes) app.register_blueprint(api_v1_routes) app.register_blueprint(sitemap_routes) Migrate(app, db) app.config.from_object(environ.get('APP_CONFIG', 'config.ProductionConfig')) db.init_app(app) manager = Manager(app) manager.add_command('db', MigrateCommand) if app.config['CACHING']: cache.init_app(app, config={'CACHE_TYPE': 'simple'}) else: cache.init_app(app, config={'CACHE_TYPE': 'null'}) CORS(app) stripe.api_key = 'SomeStripeKey' app.secret_key = 'super secret key' app.json_encoder = MiniJSONEncoder app.config['BABEL_DEFAULT_LOCALE'] = 'en' app.config['JSONIFY_PRETTYPRINT_REGULAR'] = False app.config['UPLOADS_FOLDER'] = os.path.realpath('.') + '/static/' app.config['FILE_SYSTEM_STORAGE_FILE_VIEW'] = 'static' app.config['STATIC_URL'] = '/static/' app.config['STATIC_ROOT'] = 'staticfiles' app.config['STATICFILES_DIRS'] = (os.path.join(BASE_DIR, 'static'), ) app.config['SQLALCHEMY_RECORD_QUERIES'] = True app.logger.addHandler(logging.StreamHandler(sys.stdout)) app.logger.setLevel(logging.WARNING) app.jinja_env.add_extension('jinja2.ext.do') app.jinja_env.add_extension('jinja2.ext.loopcontrols') app.jinja_env.undefined = SilentUndefined app.jinja_env.filters['operation_name'] = operation_name # set up jwt app.config['JWT_AUTH_USERNAME_KEY'] = 'email' app.config['JWT_EXPIRATION_DELTA'] = timedelta(seconds=24 * 60 * 60) app.config['JWT_AUTH_URL_RULE'] = None jwt = JWT(app, jwt_authenticate, jwt_identity) # setup celery app.config['CELERY_BROKER_URL'] = environ.get('REDIS_URL', 'redis://localhost:6379/0') app.config['CELERY_RESULT_BACKEND'] = app.config['CELERY_BROKER_URL'] HTMLMIN(app) admin_view = AdminView("Open Event") admin_view.init(app) admin_view.init_login(app) if app.config['TESTING']: # Profiling app.config['PROFILE'] = True app.wsgi_app = ProfilerMiddleware(app.wsgi_app, restrictions=[30]) # API version 2 with app.app_context(): from app.api import api_v2 app.register_blueprint(api_v2) sa.orm.configure_mappers() return app, manager, db, jwt