Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
859 B
4
Indexable
Never
import requests

account_id = ['']
bearer = ['']
worker_name = ['']
sub_domain_name = ['mynewsubdomain']


for z in worker_name:
    for i, j, s in zip(bearer, account_id, sub_domain_name):
        headers = {
            'Content-Type': 'application/javascript',
            'Authorization': 'Bearer '+i
        }
        headers1 = {
            'Content-Type': 'application/json',
            'Authorization': 'Bearer '+i
        }
        data1 = {"subdomain":s}
        response1 = requests.put(
            'https://api.cloudflare.com/client/v4/accounts/'+j+'/workers/subdomain',
            headers=headers1,
            json=data1,
        )

        if response1.status_code == 200:
            print('Worker Created Enabled: ', response1.json())
        else:
            print('Error Creating Worker:', response1.json())