Dalleon commited on
Commit
17033ea
1 Parent(s): 14c2921

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -20
app.py CHANGED
@@ -4,12 +4,10 @@ import gradio as gr
4
  import threading
5
  import requests
6
  import socket
 
7
 
8
 
9
  url_list = [
10
- "spiny-upbeat-lingonberry.glitch.me",
11
- "hwooded-near-science.glitch.me",
12
- "airzy.glitch.me",
13
  "bubble-magnificent-bicycle.glitch.me"
14
  ]
15
 
@@ -43,22 +41,16 @@ result_string += "\n[Ready]\n"
43
  # Main loop for sending requests
44
  while True:
45
  result_counter2 += 1
46
- for url in url_list:
47
- try:
48
- ip = socket.gethostbyname(url)
49
- print(f'{hostname} resolved to {ip}')
50
- url = f'https://{hostname}/api/wake'
51
- payload = {"data": "test"} # Replace with your actual payload
52
- headers = {"Content-Type": "application/json"}
 
 
 
 
53
 
54
- response = requests.post(url, json=payload, headers=headers)
55
- response.raise_for_status() # Raise an error for bad status codes
56
- print(response.text) # Print the response from the server
57
-
58
-
59
- result_counter += 1
60
- except requests.exceptions.RequestException as e:
61
- print(f"Error ({url}):", str(e))
62
- result_string += f"\n({result_counter})[ERROR] {str(e)}\n in ({url})\n\n"
63
-
64
  time.sleep(120) # 120 seconds
 
4
  import threading
5
  import requests
6
  import socket
7
+ import dns.resolver
8
 
9
 
10
  url_list = [
 
 
 
11
  "bubble-magnificent-bicycle.glitch.me"
12
  ]
13
 
 
41
  # Main loop for sending requests
42
  while True:
43
  result_counter2 += 1
44
+ try:
45
+ result = dns.resolver.resolve('bubble-magnificent-bicycle.glitch.me', 'A')
46
+ for ipval in result:
47
+ print('IP', ipval.to_text())
48
+ result_counter += 1
49
+ except dns.resolver.NoAnswer:
50
+ print('No answer')
51
+ except dns.resolver.NXDOMAIN:
52
+ print('Domain does not exist')
53
+ except Exception as e:
54
+ print(f'Error: {e}')
55
 
 
 
 
 
 
 
 
 
 
 
56
  time.sleep(120) # 120 seconds