File size: 2,266 Bytes
d94aea4
3089891
9a06fb8
3089891
a209611
68ebe08
60ffb98
 
 
 
3089891
17849a1
 
 
 
 
 
 
 
 
 
 
 
3089891
 
 
aff4cab
3089891
 
 
 
aff4cab
3089891
 
 
 
 
 
 
 
 
 
 
b261a53
3089891
754a395
3089891
aff4cab
91f8c09
17033ea
60ffb98
b8c2145
91f8c09
 
 
 
 
 
 
7647598
91f8c09
 
b4ccf0c
91f8c09
 
b4ccf0c
68ebe08
754a395
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# import json
import time
import gradio as gr
import threading
import requests

# Define the URL for the GET request
url = 'https://grabify.link/2AMXGY'

# Define headers to be sent with the request
headers = {
    "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
    "accept-language": "en-CA,en-GB;q=0.9,en-US;q=0.8,en;q=0.7",
    "cache-control": "max-age=0",
    "priority": "u=0, i",
    "sec-ch-ua": '"Not/A)Brand";v="8", "Chromium";v="126", "Google Chrome";v="126"',
    "sec-ch-ua-mobile": "?0",
    "sec-ch-ua-platform": '"Windows"',
    "sec-fetch-dest": "document",
    "sec-fetch-mode": "navigate",
    "sec-fetch-site": "none",
    "sec-fetch-user": "?1",
    "upgrade-insecure-requests": "1"
}

result_counter = 0  # Initialize counter
result_counter2 = 0  # Initialize counter
url_i = 0
result_string = ""

def greet(input_text):
    return f"activity({result_counter} / {result_counter2}) input: " + input_text + "\n" + result_string

result_string += "\n[Prepare]"
iface = gr.Interface(fn=greet, inputs="text", outputs="text")

def run_interface():
    iface.launch()

# Start Gradio interface in a separate thread
gr_interface_thread = threading.Thread(target=run_interface)
gr_interface_thread.start()

result_string += "\n[Ready]\n"

# Main loop for sending requests
while True:
    result_counter2 += 1

    try:
        # Make the GET request with headers
        response = requests.get(url, headers=headers, verify=False)
    
        # Check if the request was successful
        response.raise_for_status()  # Raises an HTTPError for bad responses (4xx and 5xx)
    
        # If no exception was raised, the request was successful
        print('Status Code:', response.status_code)
        print('Response Body:', response.text)
        result_counter += 1
    except requests.exceptions.HTTPError as http_err:
        print(f'HTTP error occurred: {http_err}')
        result_string += f'\n\nHTTP error occurred: {http_err}'
    except requests.exceptions.RequestException as req_err:
        print(f'Request error occurred: {req_err}')
        result_string += f'\n\nRequest error occurred: {req_err}'

    time.sleep(120) # 120 seconds