def create_app(**config_overrides): """This is normal setup code for a Flask app, but we give the option to provide override configurations so that in testing, a different database can be used. """ from app.routes.base import register_error_handlers # we want to modify the global app, not a local copy global app global adi global assets global gcal_client app = Flask(__name__) # Load config then apply overrides app.config.from_object("config.flask_config") app.config.update(config_overrides) # Initialize assets assets = Environment(app) register_scss() # Setup the database. db.init_app(app) # Attach Blueprints (routing) to the app register_blueprints(app) # Attache error handling functions to the app register_error_handlers(app) # Register the logger. register_logger(app) return app
def create_app(**config_overrides): from app.routes.base import register_error_handlers # we want to modify the global app, not a local copy global app global assets app = Flask(__name__) # Load config then apply overrides app.config.from_object('config.flask_config') app.config.update(config_overrides) # Initialize assets assets = Environment(app) register_scss() # Setup the database. db.init_app(app) # Attach Blueprints (routing) to the app register_blueprints(app) # Attache error handling functions to the app register_error_handlers(app) # Register the logger. register_logger(app) return app
def create_app(**config_overrides): """This is normal setup code for a Flask app, but we give the option to provide override configurations so that in testing, a different database can be used. """ from app.routes.base import register_error_handlers # we want to modify the global app, not a local copy global app global assets app = Flask(__name__) # Load config then apply overrides app.config.from_object('config.flask_config') app.config.update(config_overrides) # Initialize assets assets = Environment(app) register_scss() # Setup the database. db.init_app(app) # Attach Blueprints (routing) to the app register_blueprints(app) # Attache error handling functions to the app register_error_handlers(app) # Register the logger. register_logger(app) return app
def create_app(**config_overrides): """This is normal setup code for a Flask app, but we give the option to provide override configurations so that in testing, a different database can be used. """ # we want to modify the global app, not a local copy global app global adi global assets global gcal_client app = Flask(__name__) # Load config then apply overrides app.config.update(config_overrides) from config import flask_config app.config.update(**flask_config.config) app.config.update(config_overrides) # load ADI specific configurations (ignore built-in methods) for attr in (x for x in dir(adi_config) if x[:2] != "__"): adi[attr] = getattr(adi_config, attr) # Initialize assets assets = Environment(app) register_scss() # Setup the database. db.init_app(app) # Initialize the Google Calendar API Client, but only if the api # credentials have been generated first. try: from app.lib.google_calendar import GoogleCalendarAPIClient gcal_client = GoogleCalendarAPIClient() except IOError: gae_environ = 'TRUE' if app.config['GOOGLE_AUTH_ENABLED'] else 'FALSE' raise Exception('Failed to find the Google Calendar credentials file ' 'at `{}`, please create it by running:\n\n' ' $ python manage.py --authorize\n' 'The environment variable GOOGLE_AUTH_ENABLED is ' 'currently set to `{}`. If set to FALSE, Google ' 'Calendar calls will fail silently.'.format( app.config['INSTALLED_APP_CREDENTIALS_PATH'], gae_environ)) exit(1) register_delete_rules() register_blueprints() from app.routes.base import register_error_handlers register_error_handlers(app) register_logger() return app
def create_app(**config_overrides): """This is normal setup code for a Flask app, but we give the option to provide override configurations so that in testing, a different database can be used. """ from app.routes.base import register_error_handlers from app.models import db, Task # we want to modify the global app, not a local copy global db global app # global adi global assets # global gcal_client app = Flask(__name__) # Load config then apply overrides app.config.from_object('config.flask_config') app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False app.config.update(config_overrides) # Setup the database. db.init_app(app) with app.app_context(): # tell sqlalchemy which app to use and create tables db.create_all() # Initialize assets assets = Environment(app) register_scss() # Attach Blueprints (routing) to the app register_blueprints(app) # Attache error handling functions to the app register_error_handlers(app) # Register the logger. register_logger(app) return app