def register_extensions(app): db.init_app(app) moment.init_app(app) csrf.init_app(app) bootstrap.init_app(app) login_manager.init_app(app) avatars.init_app(app)
def register_extensions(app): db.init_app(app) bootstrap.init_app(app) moment.init_app(app) whooshee.init_app(app) loginmanager.init_app(app) mail.init_app(app)
def create_app(): app = Flask(__name__) app.config.from_envvar('CALAPHIO_CONFIG') # Register Blueprints app.register_blueprint(core) # Register Jinja Filters app.jinja_env.filters['sanitize_html'] = sanitize_html # Extensions db.init_app(app) login_manager.init_app(app) csrf.init_app(app) bootstrap.init_app(app) nav.init_app(app) principal.init_app(app) register_renderer(app, "renderer", BetterBootstrapRenderer) # Method Rewriter app.wsgi_app = MethodRewriteMiddleware(app.wsgi_app) # Identity Loader identity_loaded.connect(on_identity_loaded, app, False) return app
def register_extensions(app): toolbar.init_app(app) bootstrap.init_app(app) db.init_app(app) login_manager.init_app(app) moment.init_app(app) dropzone.init_app(app) whooshee.init_app(app)
def register_extensions(app): bootstrap.init_app(app) db.init_app(app) login_manager.init_app(app) csrf.init_app(app) ckeditor.init_app(app) mail.init_app(app) moment.init_app(app)
def extension(app): csrf.init_app(app) moment.init_app(app) migrate.init_app(app) bootstrap.init_app(app) login_manager.init_app(app) db.init_app(app) return None
def register_extensions(app): bootstrap.init_app(app) db.init_app(app) login_manager.init_app(app) mail.init_app(app) dropzone.init_app(app) moment.init_app(app) whooshee.init_app(app) avatars.init_app(app) csrf.init_app(app)
def create_app(): app_init = Flask(__name__) app_init.config.from_object('config') db.init_app(app_init) db.app = app_init bootstrap.init_app(app_init) migrate.init_app(app_init, db) if app_init.config['DEBUG'] is True: app_init.config['DEBUG_TB_INTERCEPT_REDIRECTS'] = False debug_toolbar.init_app(app_init) return app_init
def create_app(config=None): app = Flask(__name__) app.config.update({'PY2NEO_HOST': 'db'}) app.config.update(config or {}) db.init_app(app) bootstrap.init_app(app) app.register_blueprint(bp) return app
def create_app(config): app = Flask("beurskrach", template_folder=TEMPLATE_FOLDER, static_folder=STATIC_FOLDER) app.config.update(config) db.init_app(app) bootstrap.init_app(app) app.register_blueprint(router) return app
def create_app(config_class=Config): app = Flask(__name__) app.config.from_object(config_class) db.init_app(app) migrate.init_app(app, db) login.init_app(app) mail.init_app(app) bootstrap.init_app(app) moment.init_app(app) celery.init_app(app) from app.errors import bp as errors_bp app.register_blueprint(errors_bp) from app.auth import bp as auth_bp app.register_blueprint(auth_bp, url_prefix='/auth') from app.main import bp as main_bp app.register_blueprint(main_bp) from app.scraping import bp as scraping_bp from app.scraping.scraper import Scraper from app.scraping import tasks app.register_blueprint(scraping_bp, url_prefix='/scraping') app.scrapers = { "rechem": tasks.rechem_routine_task, "test_task": tasks.test_task } if not app.debug and not app.testing: if app.config['LOG_TO_STDOUT']: stream_handler = logging.StreamHandler() stream_handler.setLevel(logging.INFO) app.logger.addHandler(stream_handler) else: if not os.path.exists('logs'): os.mkdir('logs') file_handler = RotatingFileHandler('logs/DNMS.log', maxBytes=10240, backupCount=10) file_handler.setFormatter( logging.Formatter('%(asctime)s %(levelname)s: %(message)s ' '[in %(pathname)s:%(lineno)d]')) file_handler.setLevel(logging.INFO) app.logger.addHandler(file_handler) app.logger.setLevel(logging.INFO) app.logger.info('DNMS startup') return app
def create_app(): app = Flask(__name__, instance_relative_config=True, instance_path=_default_instance_path) app.config.from_pyfile('config.py') bootstrap.init_app(app) db.init_app(app) register_blueprint(app) return app
def create_app(config=None): app = Flask(__name__) app.config.update({ 'PY2NEO_HOST': 'db', 'PY2NEO_USER': '******', 'PY2NEO_PASSWORD': '******' }) app.config.update(config or {}) db.init_app(app) bootstrap.init_app(app) app.register_blueprint(bp) return app
def create_app(config_file='app_config.py'): app = Flask(__name__) app.config.from_pyfile(config_file) ckeditor.init_app(app) bootstrap.init_app(app) mail.init_app(app) db.init_app(app) login_manager.init_app(app) search.init_app(app) gravatar.init_app(app) csrf_protection.init_app(app) flask_api.init_app(app) @login_manager.user_loader def load_user(user_id): requested_user = User.query.get(user_id) return requested_user app.register_blueprint(home) app.register_blueprint(post) app.register_blueprint(comment) app.register_blueprint(search_routing) app.register_blueprint(about_routing) app.register_blueprint(verification) app.register_blueprint(user_operations) app.register_blueprint(api) app.register_blueprint(contact_routing) app.register_blueprint(notification_routing) app.register_blueprint(reply) app.register_blueprint(website_settings) app.register_blueprint(login_system) app.register_blueprint(newsletter) app.register_blueprint(twitter_blueprint) app.register_blueprint(oauth_routing) app.register_blueprint(github_blueprint) app.register_blueprint(google_blueprint) app.register_error_handler(400, bad_request) app.register_error_handler(403, forbidden) app.register_error_handler(404, not_found) app.register_error_handler(500, internal_error) app.register_error_handler(401, unauthorized) return app
def create_app(config_name): app = Flask(__name__) app.config.from_object(config[config_name]) config[config_name].init_app(app) bootstrap.init_app(app) mail.init_app(app) moment.init_app(app) db.init_app(app) login_manager.init_app(app) pagedown.init_app(app) flask_admin.init_app(app) configure_uploads(app, photos) patch_request_class(app) flask_admin.add_view(PostModelView(Post, db.session, name='博文管理')) flask_admin.add_view(UserModelView(User, db.session, name='用户管理')) flask_admin.add_view(RoleModelView(Role, db.session, name='身份管理')) path = os.path.join(os.path.dirname(__file__), 'static') flask_admin.add_view(MyFileAdmin(path, '/static', name='文件管理')) handler = logging.FileHandler('flask_error.log', encoding='UTF-8') handler.setLevel(logging.DEBUG) logging_format = logging.Formatter( '%(asctime)s - %(levelname)s - %(filename)s - %(funcName)s - %(lineno)s - %(message)s') handler.setFormatter(logging_format) app.logger.addHandler(handler) from .main import main as main_blueprint app.register_blueprint(main_blueprint) from .auth import auth as auth_blueprint app.register_blueprint(auth_blueprint, url_prefix='/auth') from .api_1_0 import api as api_1_0_blueprint app.register_blueprint(api_1_0_blueprint, url_prefix='/api/v1.0') from .pic import pic as pic_blueprint app.register_blueprint(pic_blueprint, url_prefix='/pic') return app
def configure_extensions(app): pages.init_app(app) bootstrap.init_app(app) app.config["BOOTSTRAP_SERVE_LOCAL"] = True db.init_app(app) app.config["db"] = db login_manager.init_app(app) app.config['ext_login_manager'] = login_manager configure_identity(app) moment.init_app(app) mail.init_app(app) app.config['ext_mail'] = mail sendmail.init_app(app) app.config['contrib_sendmail'] = sendmail
def create_app(name, config_name='development'): app = Flask(name) app.root_path = os.path.dirname(os.path.abspath(__file__)) app.config.from_object(config[config_name]) fd = open(config[config_name].cfg_file_name, 'r') cfg = json.loads(fd.read()) app.config.from_mapping(cfg) config[config_name].init_app(app) init_logging(logger, cfg) mail.init_app(app) db.init_app(app) login_manager.init_app(app) pagedown.init_app(app) cors.init_app(app) bootstrap.init_app(app) app.register_blueprint(auth_blueprint, url_prefix='/auth') app.register_blueprint(main_blueprint, url_prefix='') # attach routes and custom error pages here return app
def create_app(config_file='app_config.py'): app = Flask(__name__) app.config.from_pyfile(config_file) db.init_app(app) login_manager.init_app(app) bootstrap.init_app(app) csrf_protection.init_app(app) mail.init_app(app) @login_manager.user_loader def load_user(user_id): requested_user = User.query.get(user_id) return requested_user app.register_blueprint(main_routing) app.register_blueprint(food_routing) app.register_blueprint(date_routing) app.register_blueprint(login_system) app.register_blueprint(verification) return app
from flask import Flask, render_template from settings import Config from flask_sqlalchemy import SQLAlchemy from flask_migrate import Migrate from extensions import bootstrap, db, login_manager, csrf import os app = Flask(__name__) app.config.from_object(Config) migrate = Migrate(app, db) bootstrap.init_app(app) db.init_app(app) login_manager.init_app(app) csrf.init_app(app) import routes, models if __name__ == '__main__': app.run()
def register_extensions(app): """Register flask extensions""" db.init_app(app) bootstrap.init_app(app) CORS(app)
def create_app(config_name): """ An flask application factory, as explained here: http://flask.pocoo.org/docs/patterns/appfactories/ Arguments: config_name: the key value if the config.config dict, e.g. 'dev', 'test', 'product', 'default' """ app = Flask(__name__) app.config.from_object(config[config_name]) # 首先调用配置对象的init_app config[config_name].init_app(app) # init SQLAlchemy db.init_app(app) # init Bcrypt bcrypt.init_app(app) # init LoginManager login_manager.init_app(app) # init Principal principal.init_app(app) @identity_loaded.connect_via(app) def on_identity_loaded(sender, identity): # Set the identity user object identity.user = current_user # Add the UserNeed to the identity if hasattr(current_user, 'id'): identity.provides.add(UserNeed(current_user.id)) # Add each role to the identity if hasattr(current_user, 'roles'): for role in current_user.roles: identity.provides.add(RoleNeed(role.name)) # init DebugToolbarExtension debug_toolbar.init_app(app) # init Cache cache.init_app(app) # init Flask-Assets assets_env.init_app(app) assets_env.register("main_css", main_css) assets_env.register("main_js", main_js) # init Flask-Admin admin.init_app(app) admin.add_view(CustomView(name='Custom')) models = [User, Role, Comment, Tag] for model in models: admin.add_view(CustomModelView(model, db.session, category='Models')) # 单独处理Post model,因为我们自定了CustomModelView的自类PostView admin.add_view(PostView(Post, db.session, category='Models')) admin.add_view(CustomFileAdmin( os.path.join(os.path.dirname(__file__), 'static'), '/static/', name='Static Files' )) # init Flask-Bootstrap bootstrap.init_app(app) # init Flask-Mail mail.init_app(app) # init Flask-Moment moment.init_app(app) ############################################################################ # init RestApi rest_api.add_resource(PostApi, '/api/post', '/api/post/<int:post_id>', endpoint='api') rest_api.add_resource(AuthApi, '/api/auth') rest_api.init_app(app) # register blueprint app.register_blueprint(blog_blueprint) app.register_blueprint(main_blueprint) app.register_blueprint(auth_blueprint) # register api blueprint app.register_blueprint(api_blueprint) return app
# -*- coding: utf-8 -*-