| 160 | def create_app(application: Flask) -> Flask: |
| 161 | from app.config import Config, configs |
| 162 | |
| 163 | application.json_provider_class = FlaskRelaxedContainerJSONProvider |
| 164 | |
| 165 | notify_environment = os.environ["NOTIFY_ENVIRONMENT"] |
| 166 | |
| 167 | if notify_environment in configs: |
| 168 | application.config.from_object(configs[notify_environment]) |
| 169 | else: |
| 170 | application.config.from_object(Config) |
| 171 | |
| 172 | application.config["NOTIFY_APP_NAME"] = application.name |
| 173 | init_app(application) |
| 174 | |
| 175 | request_helper.init_app(application) |
| 176 | db.init_app(application) |
| 177 | migrate.init_app(application, db=db) |
| 178 | ma.init_app(application) |
| 179 | utils_logging.init_app(application) |
| 180 | |
| 181 | notify_celery.init_app(application) |
| 182 | signing.init_app(application) |
| 183 | redis_store.init_app(application) |
| 184 | |
| 185 | register_blueprint(application) |
| 186 | register_v2_blueprints(application) |
| 187 | |
| 188 | # avoid circular imports by importing this file later |
| 189 | from app.commands import setup_commands |
| 190 | |
| 191 | setup_commands(application) |
| 192 | |
| 193 | # set up sqlalchemy events |
| 194 | setup_sqlalchemy_events(application) |
| 195 | |
| 196 | return application |
| 197 | |
| 198 | |
| 199 | def reset_memos(): |
| 200 | """ |
| 201 | Reset all memos registered in memo_resetters |