def create_app() -> Callable[[Any, Any], Any]: ''' Create a WSGI compatible App object. ''' validate_config() coloredlogs.install(fmt='[%(asctime)-15s] %(name)s %(message)s') logging.getLogger('elasticsearch').disabled = True if config.config['debug']: logging.getLogger('szurubooru').setLevel(logging.INFO) if config.config['show_sql']: logging.getLogger('sqlalchemy.engine').setLevel(logging.INFO) purge_thread = threading.Thread(target=purge_old_uploads) purge_thread.daemon = True purge_thread.start() try: posts.populate_reverse_search() db.session.commit() except errors.ThirdPartyError: pass rest.errors.handle(errors.AuthError, _on_auth_error) rest.errors.handle(errors.ValidationError, _on_validation_error) rest.errors.handle(errors.SearchError, _on_search_error) rest.errors.handle(errors.IntegrityError, _on_integrity_error) rest.errors.handle(errors.NotFoundError, _on_not_found_error) rest.errors.handle(errors.ProcessingError, _on_processing_error) rest.errors.handle(errors.ThirdPartyError, _on_third_party_error) rest.errors.handle(sa.orm.exc.StaleDataError, _on_stale_data_error) return rest.application