def create_site_app(**kwargs): """Create a template Flask app""" app = create_app(**kwargs) from . import views # this must be placed here, after the app is created app.register_blueprints() return app
# the main Flask application from logic import create_app app = create_app() if __name__ == "__main__": app.run(**app.config['INIT'])
import logging from logic.models import User from flask import session from logic import create_app, db, models from flask_migrate import Migrate, MigrateCommand from flask_script import Manager # create_app类似于工厂方法 app = create_app('development') # 将app与Manager关联 manager = Manager(app) # 数据库迁移,将app与db关联 Migrate(app, db) # 将迁移命令添加到manager manager.add_command("db", MigrateCommand) @manager.option("-n", "-name", dest="name") @manager.option("-p", "-password", dest="password") def create_admin(name, password): if not all([name, password]): print("参数错误") user = User() user.nick_name = name user.mobile = name user.password = password user.is_admin = True
def app(): """New app for test mode""" app = create_app(config='TestConfig') return app
def create_core_app(**kwargs): """Create a template Flask app""" app = create_app(**kwargs) return app
from logic import create_app, db, models from flask_script import Manager from flask_migrate import Migrate, MigrateCommand # 创建app app = create_app('dev') # 创建脚本管理对象 manger = Manager(app) # 让迁移和app和db建立联系 Migrate(app, db) # 将迁移的脚本命令添加到manager manger.add_command("mysql", MigrateCommand) if __name__ == '__main__': print(app.url_map) manger.run()