def create_app(env=os.environ.get("FLASK_ENV")): """Application factory.""" logging.basicConfig( level=logging.INFO, format=("[%(asctime)s] [sev %(levelno)s] [%(levelname)s] " "[%(name)s]> %(message)s"), datefmt="%a, %d %b %Y %H:%M:%S") # Disable werkzeug logging under WARNING. logging.getLogger("werkzeug").setLevel(logging.WARNING) app = Flask(__name__) app.logger.info(f"Loading env {env}") configurations = { "dev-local": "shhh.config.DefaultConfig", "dev-docker": "shhh.config.DockerConfig", "heroku": "shhh.config.HerokuConfig", "production": "shhh.config.ProductionConfig", } app.config.from_object( configurations.get(env, "shhh.config.ProductionConfig")) db.init_app(app) scheduler.init_app(app) with app.app_context(): register_blueprints(app) db.create_all() scheduler.start() from shhh import views return app
def register_extensions(app): """Register application extensions.""" assets.init_app(app) db.init_app(app) try: scheduler.init_app(app) except SchedulerAlreadyRunningError: pass
def register_extensions(app): """Register application extensions.""" assets.init_app(app) db.init_app(app) scheduler.init_app(app)