Exemple #1
0
def create_test_app():
    app = Flask(__name__)
    load_dotenv('./environments/test.env')
    for item in environ.items():
        app.config[item[0]] = item[1]
    db.init_app(app)
    db.drop_all()
    Schema.migration()
    Schema.prepare_db()
    initialize_resources(app)
    return app
Exemple #2
0
def create_test_app():
    global db
    global app

    app = Flask(__name__)
    load_dotenv('./environments/local.env')
    for item in environ.items():
        app.config[item[0]] = item[1]
    app.app_context().push()

    db.init_app(app)
    db.reflect()
    db.drop_all()

    initialize_database(app)
    initialize_resources(app)

    Schema.migration()
    Schema.prepare_db()
Exemple #3
0
application = Flask(__name__)

# Loading environment variables from .env file only in development
if environ.get('EBS_ENVIRONMENT') in ['local', None]:
    print('Loading environment variables from .env file')
    load_dotenv('./environments/local.env')

# Loading environment variables into Flask application
for item in environ.items():
    application.config[item[0]] = item[1]

# Starting database configuration
initialize_database(application)

# Starting RESTful endpoints
initialize_resources(application)


@application.before_first_request
def startup():
    print("Initializing migration DB")
    # engine = create_engine(application.config['SQLALCHEMY_DATABASE_URI'], echo=False)
    # UserModel.__table__.drop(engine)

    Schema.migration()
    Schema.prepare_db()


# Run application
if __name__ == '__main__':
    application.run(threaded=True)