Upload warmer.py
Browse files
warmer.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import requests
|
2 |
+
import time
|
3 |
+
import os
|
4 |
+
|
5 |
+
print("RAN")
|
6 |
+
hf_token_id = os.environ['TOKEN']
|
7 |
+
bearer_hf_token = "Bearer "+hf_token_id
|
8 |
+
|
9 |
+
headers = {"Authorization" : bearer_hf_token}
|
10 |
+
|
11 |
+
while True:
|
12 |
+
try:
|
13 |
+
response = requests.get('https://reverent-atlei2.hf.space/', headers=headers)
|
14 |
+
print(int(response.status_code))
|
15 |
+
if response.status_code == 200:
|
16 |
+
print("ALIVE")
|
17 |
+
else:
|
18 |
+
print("DISCONNECTED")
|
19 |
+
time.sleep(60)
|
20 |
+
except Exception as e:
|
21 |
+
print("NO INTERNET")
|
22 |
+
print(str(e))
|