def create_app(): app = Flask(__name__) app.debug = True app.testing = False import config app.config.from_object(config) app.config['SHELF_PAGES'] = { "index": (IndexPage, IndexPageModelView), "contact": (ContactPage, ContactPageModelView), } with app.app_context(): db.init_app(app) db.create_all() babel = Babel(app) shlf = Shelf(app) shlf.init_db(db) dview = DashboardView() shlf.init_admin(index_view=dview) shlf.init_security(User, Role) shlf.load_plugins(( "shelf.plugins.dashboard", "shelf.plugins.i18n", "shelf.plugins.library", "shelf.plugins.page", "shelf.plugins.preview", "shelf.plugins.workflow", "shelf.plugins.wysiwyg", "shelf.plugins.ecommerce", )) init_admin(shlf.admin, db.session) shlf.setup_plugins() page = shlf.get_plugin_by_class(PagePlugin) page.register_pages(app, shlf.db) init_views(app) init_filters(app) return app
app.config['SECURITY_PASSWORD_SALT'] = 'mysalt'#"hash_123678*", app.config['SECURITY_SEND_REGISTER_EMAIL'] = False app.config['APP_ROOT'] = os.path.dirname(os.path.abspath(__file__)) app.config['APP_STATIC'] = os.path.join(app.config['APP_ROOT'], 'static') app.config['MEDIA_ROOT'] = os.path.join(app.config['APP_STATIC'], 'media') app.config['MEDIA_URL'] = '/static/media/' try: os.makedirs(app.config['MEDIA_ROOT']) except OSError: pass with app.app_context(): db.init_app(app) db.app = app shlf = Shelf(app) shlf.init_db(db) shlf.init_admin() shlf.init_security(User, Role) shlf.load_plugins(( "shelf.plugins.wysiwyg", "shelf.plugins.workflow", "shelf.plugins.library" )) shlf.admin.add_view(admin.PostModelView(model.Post, db.session)) shlf.admin.add_view(FileAdmin(name="Media")) shlf.setup_plugins() app.run('0.0.0.0')