def create_app(config=config_env): app = Flask(__name__) app.config.from_object(config) app.register_blueprint(library) app.register_blueprint(library_books) app.register_blueprint(library_book_borrowing_dashboard) app.secret_key = os.urandom(24) mail.init_app(app) db.init_app(app) ma.init_app(app) wait_for_db(app) return app
def create_app(conf): """ 初始化app """ # 获取配置 app.config.from_object(conf) # 初始化扩展 admin.init_app(app) db.init_app(app) sec.init_app(app) return app
def create_app(): app = Flask(__name__) POSTGRES = { 'user': '******', 'pw': 'password', 'db': 'todolist', 'host': 'localhost', 'port': '5432', } app.config['SQLALCHEMY_DATABASE_URI'] \ = 'postgresql://%(user)s:%(pw)s@%(host)s:%(port)s/%(db)s' % POSTGRES app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False app.register_blueprint(todolist) app.secret_key = os.urandom(24) db.init_app(app) return app
def create_app(config=config_env): app = Flask(__name__) app.config.from_object(config) app.register_blueprint(library) app.register_blueprint(library_books) app.register_blueprint(library_book_borrowing_dashboard) app.secret_key = os.urandom(24) mail.init_app(app) db_not_ready = True while db_not_ready: try: db.init_app(app) with app.app_context(): db.create_all() db_not_ready = False except: print("DB not ready!") print("Polling DB..") time.sleep(1) ma.init_app(app) return app
from flask import Flask from config import Config from init_db import db from views.department import department from views.employee import employee from views.home import home app = Flask(__name__) app.config.from_object(Config) app.secret_key = "Secret Key" db.init_app(app) def create_app(): app.register_blueprint(department) app.register_blueprint(employee) app.register_blueprint(home) return app