def create_app(self): self.assertTrue(conf.jarr_testing, "configuration not set on testing") from jarr.api import create_app self._application = create_app(testing=True) return self._application
#! /usr/bin/env python # -*- coding: utf-8 -*- from werkzeug.middleware.proxy_fix import ProxyFix from jarr.api import create_app application = ProxyFix(create_app(), x_for=1, x_proto=1, x_host=1, x_port=1)
#! /usr/bin/env python # -*- coding: utf-8 -*- import logging from datetime import datetime, timedelta, timezone from flask_migrate import Migrate, MigrateCommand from flask_script import Manager from jarr.api import create_app from jarr.bootstrap import Base, conf from jarr.controllers import FeedController, UserController from jarr.lib.utils import utc_now application = create_app() logger = logging.getLogger(__name__) Migrate(application, Base) manager = Manager(application) manager.add_command('db', MigrateCommand) @manager.command def db_create(login='******', password='******'): """Will create the database from conf parameters.""" admin = { 'is_admin': True, 'is_api': True, 'login': login, 'password': password } Base.metadata.create_all()
#! /usr/bin/env python # -*- coding: utf-8 -*- import click from werkzeug.middleware.proxy_fix import ProxyFix from jarr.api import create_app from jarr.bootstrap import Base from flask_migrate import Migrate _app = create_app() application = ProxyFix(_app, x_for=1, x_proto=1, x_host=1, x_port=1) migrate = Migrate(db=Base) migrate.init_app(_app) @_app.cli.command("bootstrap-database") @click.option("--admin_login", default="admin") @click.option("--admin_password", default="admin") def bootstrap_database(admin_login, admin_password): """Will create the database from conf parameters.""" from jarr.controllers.user import UserController admin = {'is_admin': True, 'is_api': True, 'login': admin_login, 'password': admin_password} Base.metadata.create_all() UserController().create(**admin)