コード例 #1
0
def init_app():
    load_config()
    set_logger()
    db.init()
    load_controllers()
    register_error_handler()
    logging.debug('Init app finished.')
    return app
コード例 #2
0
ファイル: models.py プロジェクト: gkrnours/plume
def init_db(database=None):
    if not database:
        database = app.config["DATABASE"]
    db.init(database)
    db.connect()
    db.create_tables([Author, Content])
    Author.create(id=1, name="author")
    db.close()
コード例 #3
0
def create_app():
    app = Flask(__name__)

    config.init(app)
    cli.init(app)
    api.init(app)
    db.init(app)

    CORS(app)

    return app
コード例 #4
0
def create_manager(case_api_client=CaseApi):
    app = FlaskAPI(__name__)
    app.config.from_pyfile('config.py')

    manager = Manager(app)
    app.register_blueprint(helloworld.blueprint)
    app.register_blueprint(deed.blueprint(case_api_client()))

    db.init(app, manager)

    return manager
コード例 #5
0
def create_manager(case_api_client=make_case_client):
    app = FlaskAPI(__name__)
    app.config.from_pyfile('config.py')

    manager = Manager(app)
    app.register_blueprint(helloworld.blueprint)
    app.register_blueprint(deed.blueprint(case_api_client()))

    db.init(app, manager)

    return manager
コード例 #6
0
def create_manager(deed_api_client=DeedApi):
    app = FlaskAPI(__name__)
    app.config.from_pyfile('config.py')

    app.register_blueprint(helloworld.blueprint)
    app.register_blueprint(key.blueprint)
    app.register_blueprint(sign.blueprint(deed_api_client()))

    manager = Manager(app)
    db.init(app, manager)

    return manager
コード例 #7
0
def init():
    if(not path.isfile(db_file)):
        print('No database was found.')
        print('If you already have a database, move it to \'database/\'.')
        print('If this is the first time you use Alohomora, you can create\n\
a new database.\n')
        print('What do you want me to do?')
        g = shell_io.key_input('(C)reate new one, E(x)it: ', ['c', 'C', 'x', 'X'])
        if(g == 'X' or g == 'x'):
            sys.exit(0)
        else:
            db.init()
            print('Database successfully created.\n\n')
コード例 #8
0
    def get_metrics(choice, sprint_id=None):
        m, key = get_metrics_tool(choice, sprint_id=sprint_id)

        create_csv_header(key)

        db.init()

        metrics = m.get_metrics(year=2018, quarter=3)

        if choice != 'g':
            for metric in metrics:
                write_csv_line(key, metric)
                dao_upsert_sprint(metric)

            dump_json(key, metrics)
コード例 #9
0
def create_manager():
    app = Flask(__name__)
    app.config.from_pyfile('config.py')

    manager = Manager(app)

    static.register_assets(app)

    app.register_blueprint(helloworld.blueprint)
    app.register_blueprint(assets.govuk_template, url_prefix='/template')
    app.register_blueprint(identity.blueprint())

    db.init(app, manager)

    return manager
コード例 #10
0
def create_manager():
    app = FlaskAPI(__name__)

    app.config.from_pyfile('config.py')

    app.register_blueprint(helloworld.blueprint)
    app.register_blueprint(home.blueprint)
    app.register_blueprint(case.blueprint)
    app.register_blueprint(borrower.blueprint)
    app.register_blueprint(property.blueprint)
    app.register_blueprint(land_registry.blueprint)

    manager = Manager(app)
    db.init(app, manager)

    return manager
コード例 #11
0
def create_app(config=None):
    # create flask app
    app = Flask(__name__, instance_relative_config=True)

    app.config.from_mapping(PROJECT_PATH=os.path.abspath(
        os.path.join(os.path.dirname(__file__), '..')))

    if config:
        app.config.update(config)

    # init all datasets
    db.init(app)

    # health check
    @app.route('/health')
    def health():
        return ''

    from app.patients.controller import bp as patients_bp

    # register patients
    app.register_blueprint(patients_bp)

    return app
コード例 #12
0
from flask import Flask
from flask_login import LoginManager

from app import db
from app import constants
from app.core.controllers.users_controller import check_super_user

app = Flask(__name__)
app.config['SECRET_KEY'] = constants.secret_key
login_manager = LoginManager()
login_manager.init_app(app)

from app.views import views

db.init()
check_super_user()

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=constants.internal_port)
コード例 #13
0
import os
import json

from app import app, db

configuration_file = os.environ.get('APP_CONFIG_FILE')
app.config['UI'] = json.load(open(configuration_file))
db.init(app.config['UI']['database'])
コード例 #14
0
ファイル: test_db.py プロジェクト: rodrigosavian/iclinic-test
 def test_get_dataset(self):
     db.init(self.app)
     result = db.get_dataset('patients')
     self.assertEqual(type(result), trie.Trie)
コード例 #15
0
ファイル: test_db.py プロジェクト: rodrigosavian/iclinic-test
 def test_init_ok(self):
     result = db.init(self.app)
     data = getattr(db, '__dataset')
     self.assertEqual(type(data), dict)
     self.assertIn('patients', data)
     self.assertEqual(type(data['patients']), trie.Trie)