def delete(self, temp_id):
        """
        Delete templates

        Arguments
        --------
        temp_id: uuid/None
            Template ID to delete or None to delete all
        """
        if temp_id:
            try:
                template = Templates.query.filter_by(id=temp_id).first()
                if not template:
                    logger.debug('No such template found')
                    abort(404)
                logger.debug('Deleting template: {}'.format(template.id.hex))
                temp_file = valid.val_filepath(path_string='{}templates/'.format(self.log_dir),
                                               file_string='{}.json'.format(template.id.hex))
                temp_file.unlink()
                db.session.delete(template)
                db.session.commit()
                return jsonify({'msg': 'Template deleted'}), 200
            except AttributeError as err:
                logger.debug('Error deleting template file: {}'.format(err))
                abort(404)
            except FileNotFoundError as err:
                logger.debug('Error deleting template file: {}'.format(err))
                return {'msg': 'API error deleting template file'}, 500
            except Exception as err:
                logger.debug('Error deleting job template: {}'.format(err))
                return {'msg': 'API error deleting template'}, 500
        else:
            for template in Templates.query.all():
                try:
                    logger.debug('Deleting template: {}'.format(template.id.hex))
                    temp_file = valid.val_filepath(path_string='{}templates/'.format(self.log_dir),
                                                   file_string='{}.json'.format(template.id.hex))
                    db.session.delete(template)
                    db.session.commit()
                    temp_file.unlink()
                except FileNotFoundError as err:
                    logger.debug('Error deleting template file: {}'.format(err))
                except Exception as err:
                    logger.debug('Error deleting job templates: {}'.format(err))
                    return {'msg': 'API error deleting template'}, 500
            return jsonify({'msg': 'Templates deleted'}), 200

        Delete templates

        Arguments
        --------
        temp_id: uuid/None
            Template ID to delete or None to delete all
        
crackq/cq_api.py