Reverent commited on
Commit
e598102
·
1 Parent(s): ddb3062

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -1,4 +1,4 @@
1
- import requests
2
  import time
3
  import os
4
  import gradio as gr
@@ -6,19 +6,21 @@ from threading import Thread
6
 
7
  print("RAN")
8
  hf_token_id = os.environ['TOKEN']
9
- bearer_hf_token = "Bearer "+hf_token_id
10
 
11
- headers = {"Authorization" : bearer_hf_token}
12
  def warmer():
13
  while True:
14
  try:
15
- response = requests.get('https://reverent-atlei2.hf.space/', headers=headers)
16
- print(int(response.status_code))
17
- if response.status_code == 200:
 
 
 
18
  print("ALIVE")
19
  else:
20
  print("DISCONNECTED")
21
- time.sleep(600)
22
  except Exception as e:
23
  print("NO INTERNET")
24
  print(str(e))
 
1
+ from gradio_client import Client
2
  import time
3
  import os
4
  import gradio as gr
 
6
 
7
  print("RAN")
8
  hf_token_id = os.environ['TOKEN']
 
9
 
10
+ client = Client("https://reverent-atlei2.hf.space/",hf_token=hf_token_id)
11
  def warmer():
12
  while True:
13
  try:
14
+ text_output = client.predict(
15
+ "ATLEIwarm0001", # str in 'message' Textbox component
16
+ "", # str (filepath or URL to image) in 'Upload any Image' Image component
17
+ api_name="/predict"
18
+ )
19
+ if text_output != None:
20
  print("ALIVE")
21
  else:
22
  print("DISCONNECTED")
23
+ time.sleep(300)
24
  except Exception as e:
25
  print("NO INTERNET")
26
  print(str(e))