def init_app(): app = Flask(__name__) app.config.from_object('app.setting') mail.init_app(app=app) configure_uploads(app, photos) patch_request_class(app, size=None) socketio.init_app(app=app) admin.init_app(app=app, index_view=MyHomeView()) babel.init_app(app=app) limiter.init_app(app=app) login_manager.init_app(app=app) login_manager.login_view = 'page_404' login_manager.login_message = '温馨提醒:请先登录或注册' # 注册sqlalchemy db.init_app(app=app) # db.drop_all(app=app) db.create_all(app=app) register_blueprint(app) return app
def create_app(): app = Flask(__name__) app.config.from_object('config') db.init_app(app) # app.register_blueprint(user_bp) app.register_blueprint(workflow_bp) CORS(app) return app
def create_app(): app = Flask(__name__) config.init_app(app) db.init_app(app) login.init_app(app) cli.init_app(app) site.init_app(app) return app
def create_app(): app = Flask(__name__) config.init_app(app) db.init_app(app) migrate.init_app(app) admin.init_app(app) login.init_app(app) vendedor.init_app(app) return app
def createApp(configObject): """ Create a flask application""" app = Flask(__name__) app.config.from_object(configObject) CORS(app, resources={r"/*": {"origins": "*"}}) db.init_app(app) app.db = db app.register_blueprint(routes) # for update app.app_context().push() app.json_encoder = MyJSONEncoder return app
def create_app(): # instanciate the app app = Flask(__name__) # app configurations app.config.from_object('app.config.Config') # setup extensions db.init_app(app) # register blueprint app.register_blueprint(shortener) return app
def create_app(config_name): app = Flask(__name__) app.config.from_object(config[config_name]) config[config_name].init_app(app) db.init_app(app) bootstrap.init_app(app) principal.init_app(app) login_manager.init_app(app) from app.auth import auth as auth_blueprint app.register_blueprint(auth_blueprint, url_prefix='/admin') return app
def create_app(config_name='default'): app = Flask(__name__) app.config.from_object(config[config_name]) config[config_name].init_app(app) db.init_app(app) from app.middleware import login_user app.before_request_funcs.setdefault(None, []).append(login_user) from app.routes.main import main as main_blueprint app.register_blueprint(main_blueprint) from app.routes.auth import auth as auth_blueprint app.register_blueprint(auth_blueprint) from app.routes.api import api_blueprint app.register_blueprint(api_blueprint) return app
def create_app(): app = Flask(__name__) # 路由支持正则 app.url_map.converters['regex'] = RegexConverter app.config.from_object("app.setting.DevelopmentConfig") from app.ext import db, login_manager, mail, csrf csrf.init_app(app) db.init_app(app) mail.init_app(app) login_manager.init_app(app) login_manager.session_protection = 'strong' login_manager.blueprint_login_views = { 'user': "******", 'admin': "admin.login", } update_config(app) register_blueprint(app) return app
def create_app(config_name='default'): ''' factory function creates and initialize app instance ''' app = Flask(__name__) app.config.from_object(config[config_name]) config[config_name].init_app(app) # init of plugins db.init_app(app) mako.init_app(app) # blueprints from app.main import main as main_blueprint app.register_blueprint(main_blueprint) # TODO: ? # http://flask.palletsprojects.com/en/1.1.x/patterns/fileuploads/ # Read source file by SharedDataMiddleware app.wsgi_app = SharedDataMiddleware(app.wsgi_app, {'/i/': app.config['UPLOAD_FOLDER']}) return app
def create_app(): app = Flask(__name__) app.config.from_object('app.config.setting') app.wsgi_app = SharedDataMiddleware(app.wsgi_app, { '/i/': get_file_path() }) mako.init_app(app) db.init_app(app) register_app(app) with app.app_context(): # db.drop_all() db.create_all() # # collection1 = Collection() # collection1.name = 'iphone' # db.session.add(collection1) # # collection2 = Collection() # collection2.name = 'artifact' # db.session.add(collection2) db.session.commit() return app
def config_extension(flask_app): from app.ext import db db.init_app(flask_app)
def register_model(app): from app.link import model db.init_app(app) db.app = app
app = Flask(__name__) app.config['SECRET_KEY'] = 'hard to guess string' app.config['SQLALCHEMY_DATABASE_URI'] = "mysql+pymysql://root:" + json_dict[ 'DB_PASSWORD'] + "@localhost:3306/robot" app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False app.config['MAIL_SERVER'] = 'smtp.126.com' app.config['MAIL_PORT'] = 25 app.config['MAIL_USE_TLS'] = True app.config['MAIL_USERNAME'] = json_dict['MAIL_USERNAME'] app.config['MAIL_PASSWORD'] = json_dict['MAIL_PASSWORD'] app.config['FLASK_MAIL_SUBJECT_PREFIX'] = '[FLASKY]' app.config['FLASK_MAIL_SENDER'] = 'Flasky Admin <*****@*****.**>' bootstrap = Bootstrap(app) moment = Moment(app) db.init_app(app) migrate = Migrate(app, db) mail = Mail(app) #manager = Manager(app) @app.shell_context_processor def make_shell_context(): return dict(db=db, User=User, Role=Role) def send_async_email(app, msg): with app.app_context(): mail.send(msg)
def _configure_extensions(app): db.init_app(app) celery.init_app(app) celery.config_from_object('app.settings.celery_config')
def register_extensions(app): ''' Register app extensions ''' cors.init_app(app) socketio.init_app(app) db.init_app(app)
def register_database(app): from app.auth import model db.init_app(app) db.app = app
def createMysqlOrm(app): """ Init the application with database setting""" with app.app_context(): db.init_app(app) app.register_blueprint(routes)