Docker - How to delete image from a private registry

This is a python script delete all image in private registry, it work on my private registry.

import requests
for repo in requests.get('https://192.168.2.31:5000/v2/_catalog', verify=False).json()['repositories']:
    headers = requests.get('https://192.168.2.31:5000/v2/%s/manifests/v1' % repo, headers = {'Accept': 'application/vnd.docker.distribution.manifest.v2+json'}, verify=False).headers
    if 'Docker-Content-Digest' in headers:
        requests.delete('https://192.168.2.31:5000/v2/%s/manifests/%s' % (repo, headers['Docker-Content-Digest']), verify=False)