Untitled

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

series = []
account_id = []
bearer = []
worker_name = []


for z in worker_name:
    for i, j in zip(bearer, account_id):
        headers = {
            'Content-Type': 'application/javascript',
            'Authorization': 'Bearer '+i
        }
        headers1 = {
            'Content-Type': 'application/json',
            'Authorization': 'Bearer '+i
        }
        with open('index.txt','r') as file:
            data = file.read()

        response = requests.put(
            'https://api.cloudflare.com/client/v4/accounts/'+j+'/workers/scripts/'+z,
            headers=headers,
            data=data,
        )

        print('Worker Created/Updated: ', response)
        data1 = {"enabled":True}
        response1 = requests.post(
            'https://api.cloudflare.com/client/v4/accounts/'+j+'/workers/services/'+z+'/environments/production/subdomain',
            headers=headers1,
            json=data1,
        )

        if response1.status_code == 200:
            print('Route Enabled: ', response1)
        else:
            print('Error Enabling Route:', response1.json())