def create_app(config_filename): app = Flask(__name__, static_url_path='', static_folder='../static', template_folder='../static') app.config.from_object(config_filename) # app.response_class = MyResponse from app.users.models import db db.init_app(app) # Blueprints from app.auth.views import auth_bp from app.users.views import users_bp from app.schools.views import schools_bp from app.meals.views import meals_bp app.register_blueprint(auth_bp, url_prefix='/api/auth') app.register_blueprint(users_bp, url_prefix='/api/users') app.register_blueprint(schools_bp, url_prefix='/api/schools') app.register_blueprint(meals_bp, url_prefix='/api/meals') CORS(app) return app
def create_app(config_filename): app = Flask(__name__) app.config.from_object(config_filename) #Init SQLAlchemy from app.users.models import db db.init_app(app) #Init flask-login from app.users.views import login_manager login_manager.init_app(app) #Blueprints from app.sites.views import sites app.register_blueprint(sites, url_prefix='/sites') from app.roles.views import roles app.register_blueprint(roles, url_prefix='/roles') from app.users.views import users app.register_blueprint(users, url_prefix='/users') return app
def create_app(config_filename): app = Flask(__name__) app.config.from_object(config_filename) app.response_class = MyResponse from app.users.models import db from app.color.models import db from app.size.models import db from app.product.models import db from app.category.models import db db.init_app(app) # Blueprints from app.users.views import users from app.color.views import color from app.size.views import size from app.product.views import product from app.category.views import category app.register_blueprint(users, url_prefix='/api/v1/users') app.register_blueprint(color, url_prefix='/api/v1/color') app.register_blueprint(size, url_prefix='/api/v1/size') app.register_blueprint(product, url_prefix='/api/v1/product') app.register_blueprint(category, url_prefix='/api/v1/category') return app
def create_app(config_name): app = Flask(__name__, template_folder='users/templates', static_folder='upload_files') 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) # Setup Flask-Security user_datastore = SQLAlchemyUserDatastore(db, User, Role) security = Security(app, user_datastore) # from .app import app as main_blueprint # from .auth import auth as auth_blueprint # from .user import user as user_blueprint # # app.register_blueprint(main_blueprint) # app.register_blueprint(auth_blueprint, url_prefix='/auth') # app.register_blueprint(user_blueprint, url_prefix='/user') # Create admin admin = flask_admin.Admin( app, 'Example: 黎光', base_template='my_master.html', template_mode='bootstrap3', ) # Add model views admin.add_view(MyModelView(Role, db.session)) admin.add_view(MyModelView(User, db.session)) if not os.path.exists(path): try: os.mkdir(path) except OSError: pass admin.add_view(fileadmin.FileAdmin(path, '/upload_files/', name='Files')) # define a context processor for merging flask-admin's template context into the # flask-security views. @security.context_processor def security_context_processor(): return dict(admin_base_template=admin.base_template, admin_view=admin.index_view, h=admin_helpers, get_url=url_for) return app
def create_app(config_filename): app = Flask(__name__) app.config.from_object(config_filename) from app.users.models import db db.init_app(app) #Blueprints from app.users.views import users app.register_blueprint(users, url_prefix='/users') return app
def create_app(config_filename): app = Flask(__name__) app.config.from_object(config_filename) from app.users.models import db db.init_app(app) #Blueprints from app.users.views import users app.register_blueprint(users, url_prefix='/users') return app
def create_app(config_filename): app = Flask(__name__) app.config.from_object(config_filename) app.response_class = MyResponse from app.users.models import db db.init_app(app) # Blueprints from app.users.views import users app.register_blueprint(users, url_prefix="/api/v1/users") return app