def create_app(config_name): app = Flask(config_name) app.config.from_object(config[config_name]) config[config_name].init_app(app) app_admin.init_app(app) babel.init_app(app) celery.init_app(app) bootstrap.init_app(app) db.init_app(app) with app.app_context(): print current_app.name db.create_all() login_manager.init_app(app) app_admin.base_template = 'layout.html' from main import main as main_blueprint from admin import admin as admin_blueprint from auth import auth as auth_blueprint app.register_blueprint(main_blueprint) app.register_blueprint(auth_blueprint, url_prefix='/auth') import os.path _dir = os.path.dirname(os.path.abspath(__file__)) app.template_folder = os.path.join(_dir, 'templates') app.static_folder = os.path.join(_dir, 'static') return app
def register_extensions(app): db.init_app(app) mail.init_app(app) celery.init_app(app) apizen.init_app(app) manager.init_app(app) migrate.init_app(app, db)
def register_extensions(app): db.init_app(app) with app.app_context(): if db.engine.url.drivername == 'sqlite': migrate.init_app(app, db, render_as_batch=True) else: migrate.init_app(app, db)
def register_extensions(app): db.init_app(app) migrate.init_app(app, db) ma.init_app(app) hobbit.init_app(app, db) cors.init_app(app) jwt.init_app(app) # photos.init_app(app) configure_uploads(app, photos) # 初始化
def create_app(): app = Flask(__name__) app.config.from_object(DevConfig) db.init_app(app) app.register_blueprint(home_blueprint) app.register_blueprint(admin_blueprint) CSRFProtect(app) @app.errorhandler(404) def page_not_found(error): return render_template('home/404.html'), 404 return app
def create_app(config): app = Flask(__name__) app.config.from_object(config) config.init_app(app) CORS(app) # db db.init_app(app) # mail mail.init_app(app) # redis redis_client.init_app(app) # register_middleware(app, AuthMiddleware) # register_extensions(app) register_blueprints(app, business_modules) return app
from app import create_app from app.exts import db app = create_app('development') from app.api import api app.register_blueprint(api) db.init_app(app) if __name__ == "__main__": app.run()
def register_extensions(app): db.init_app(app) from app import models db.create_all(app=app)
def create_app(test_config=None): # create and configure the app app = Flask(__name__, instance_relative_config=True) CORS(app) bootstrap.init_app(app) app.config.from_object(configs) #restful显示中文 app.config.update(RESTFUL_JSON=dict(ensure_ascii=False)) app.config['JSON_AS_ASCII'] = False with app.app_context(): db.init_app(app) #初始化db # auth.init_app(app) #初始化httpauth # user1 = User(username='******', password='******') # user2 = User(username='******', password='******') # db.session.add_all([user1,user2]) # db.session.commit() # db.drop_all() # db.create_all() # app.app_context().push() # with app.app_context(): # db.init_app(app) # db.create_all() app.config.from_mapping( SECRET_KEY='dev', DATABASE=os.path.join(app.instance_path, 'Flask-QA.sqlite'), ) if test_config is None: # load the instance config, if it exists, when not testing app.config.from_pyfile('config.py', silent=True) else: # load the test config if passed in app.config.from_mapping(test_config) # ensure the instance folder exists try: os.makedirs(app.instance_path) except OSError: pass # # a simple page that says hello @app.route('/') def index(): return render_template('dist/index.html') # app.register_blueprint(forms.wtf) app.register_blueprint(RestfulApi.RestfulApi) app.register_blueprint(User_permissions_api.user_permissions) app.register_blueprint(AuthorityApi.AuthorityApi) app.register_blueprint(AuxiliaryFunction.AuxiliaryFunction) app.register_blueprint(Restful.Tree_api.OperationTree) app.register_blueprint(Upload_file.RestfulFile) app.register_blueprint(Restful.TestCaseApi.TestCaseApi) app.register_blueprint(Restful.Timing_task.Unattended) app.register_blueprint(Restful.AnalysisLog.AnalysisLog) app.register_blueprint(Restful.GenerateScripts.GenerateScripts) app.register_blueprint(Restful.LogApi.LogApi) app.register_blueprint(Restful.MonitorResult.MonitorResult) app.register_blueprint(Pressure_test_monitoring.Pressure_monitor) app.app_context().push() # app.add_url_rule('/', endpoint='dist') return app
def create_app(): app = Flask(__name__) app.config.from_object("config") app.register_blueprint(bp) db.init_app(app) return app