def create_app(config_name): app = Flask(__name__) app.config.from_object(config[config_name]) config[config_name].init_app(app) #flask_wtf.CsrfProtect(app) bootstrap.init_app(app) #mail.init_app(app) moment.init_app(app) db.init_app(app) login_manager.init_app(app) admin.init_app(app) 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') return app
class AnotherAdminView(admin.BaseView): @admin.expose('/') def index(self): return self.render('anotheradmin.html') @admin.expose('/test/') def test(self): return self.render('test.html') # Create flask app app = Flask(__name__, template_folder='templates') app.debug = True # Flask views @app.route('/') def index(): return '<a href="/admin/">Click me to get to Admin!</a>' # Create admin interface admin = admin.Admin(name="Example: Simple Views") admin.add_view(MyAdminView(name="view1", category='Test')) admin.add_view(AnotherAdminView(name="view2", category='Test')) admin.init_app(app) if __name__ == '__main__': # Start app app.run()
name='Home', template='admin/index.html', menu_icon_type=ICON_TYPE_FONT_AWESOME, menu_icon_value='fa-dashboard fa-fw', ), template_mode='sb-admin-v2', category_icon_classes={ 'Home': 'fa fa-dashboard fa-fw', 'Test': 'fa fa-bar-chart-o fa-fw', }, ) admin.add_view(MyAdminView( name="view1", category='Test', )) admin.add_view(AnotherAdminView(name="view2", category='Test')) admin.init_app(app) if __name__ == '__main__': # Start app app.run() # admin = Admin( # app, # index_view=AdminIndexView( # name='Home', # template='admin/myhome.html', # url='/' # ) # )