def create_app(config=None): app = Flask(__name__) if config is None: config = os.path.join( app.root_path, os.environ.get('FLASK_APPLICATION_SETTINGS') ) app.config.from_pyfile(config) app.secret_key = app.config['SECRET_KEY'] db.init_app(app) migrate.init_app(app, db) sec_state = security.init_app(app) admin.init_app(app) admin.add_view(UserAdmin(User, db.session, category="Accounts")) admin.add_view(RoleAdmin(Role, db.session, category="Accounts")) @sec_state.context_processor def security_context_processor(): return dict( admin_base_template=admin.base_template, admin_view=admin.index_view, h=admin_helpers, ) app.register_blueprint(cart) return app
def create_app(config_name): app = Flask(__name__) app.config.from_object(config[config_name]) config[config_name].init_app(app) app.session_interface = RedisSessionInterface() bootstrap.init_app(app) mail.init_app(app) moment.init_app(app) # user_datastore = SQLAlchemyUserDatastore(db, User, Role) security.init_app(app, datastore=user_datastore) db.init_app(app) admin.init_app(app) sess.init_app(app) # security.init_app(app) # toolbar.init_app(app) from .main import main as main_blueprint app.register_blueprint(main_blueprint) from .api import api as api_blueprint app.register_blueprint(api_blueprint, url_prefix='/api/v1') from .auth import auth as auth_blueprint app.register_blueprint(auth_blueprint, url_prefix='/auth') return app
def create_app(config_class=Config): app = Flask(__name__) app.config.from_object(config_class) bootstrap.init_app(app) db.init_app(app) login.init_app(app) moment.init_app(app) admin.init_app(app) from app.main import bp as main_bp app.register_blueprint(main_bp) from app.auth import bp as auth_bp app.register_blueprint(auth_bp) from app.error import bp as error_bp app.register_blueprint(error_bp) from app.article import bp as article_bp app.register_blueprint(article_bp) from app.post import bp as post_bp app.register_blueprint(post_bp) return app
def create_app(): from app.admin import admin app = Flask(__name__, instance_relative_config=True) app.config.from_pyfile('config.py') db.init_app(app) login_manager.init_app(app) admin.init_app(app) register_blueprints(app) return app
def create_app(conf=config.Config): app = Flask(__name__) app.config.from_object(conf) db.init_app(app) migrate.init_app(app, db) login_manager.init_app(app) mail.init_app(app) admin.init_app(app) csrf.init_app(app) configure_routes(app) return app
def register_extensions(app): app.config.from_object(CONFIG) app.config['JSON_AS_ASCII'] = False app.url_map.converters['re'] = RegexConverter db.init_app(app) migrate.init_app(app=app, db=db) admin.init_app(app) login_manager.init_app(app) babel.init_app(app) app.config['BABEL_DEFAULT_LOCALE'] = 'zh_CN' app.config['BOOTSTRAP_SERVE_LOCAL'] = True Bootstrap(app) CSRFProtect(app) nav.init_app(app)
def create_app(config): app = Flask(__name__) CORS(app) app.config['SECRET_KEY'] = os.environ.get("SECRET_KEY") app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get("DATABASE_URI") #api_manager = APIManager(app, flask_sqlalchemy_db=db) #api_manager.create_api(Employee, methods=['GET', 'POST', 'PUT', 'DELETE']) app.config.from_object(config) app.register_blueprint(blp) db.init_app(app) admin.init_app(app) migrate = Migrate(app, db) with app.app_context(): db.create_all() return app
def create_app(config_name="default"): app = Flask(__name__, static_url_path="") app.config.from_object(config[config_name]) config[config_name].init_app(app) mail.init_app(app) db.init_app(app) swagger.init_app(app) CORS(app, supports_credentials=True) pool = redis.ConnectionPool(host=app.config["REDIS_HOST"], port=app.config["REDIS_PORT"], decode_responses=True) app.sredis = redis.StrictRedis(connection_pool=pool) app.sredisPipe = app.sredis.pipeline(transaction=True) celery.conf.update(app.config) admin.init_app(app) from app.apiv1 import api as api_blueprint app.register_blueprint(api_blueprint, url_prefix="/api/v1/oee") return app
def create_app(config_name): if config_name not in app_config: raise ConfigError("{} is a wrong config name.".format(config_name)) app = Flask(__name__) app.config.from_object(app_config[config_name]) from app.user import user_blueprint from app.information import info_blueprint from app.view import view_blueprint app.register_blueprint(user_blueprint) app.register_blueprint(info_blueprint) app.register_blueprint(view_blueprint) from app.extensions import display_plan_type, display_play, display_user, tracer_config jinja_env = app.jinja_env jinja_env.filters['plan_type'] = display_plan_type jinja_env.filters['plan_name'] = display_play jinja_env.filters['user_type'] = display_user db.init_app(app) tool_bar.init_app(app) login_manager.init_app(app) admin.init_app(app) if app.config.get("TRACER"): initialize_tracer() @app.before_request def init_tracer(): import opentracing span = opentracing.tracer.start_span(str(request.url)) span.set_tag('user_agent', request.user_agent) span.log_event("request args", payload=dict(args=request.args, form=request.form)) g.tracer_span = span @app.after_request def close_tracer(response): if g.tracer_span: g.tracer_span.finish() return response return app
def create_app(): app = Flask(__name__) app.config.from_object('app.config.ProdConfig') app.secret_key = os.environ['SECRET_KEY'] app.config["SQLALCHEMY_DATABASE_URI"] = os.environ['DATABASE_URL'] app.register_blueprint(blp) db.init_app(app) admin.init_app(app) with app.app_context(): db.create_all() migrate = Migrate(app, db) return app, migrate
def initialize_extensions(app): db.init_app(app) admin.init_app(app)