epinapala commited on
Commit
c541f5d
·
verified ·
1 Parent(s): 6878e82

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -25
app.py CHANGED
@@ -7,33 +7,9 @@ import io
7
  from PIL import Image
8
  import base64
9
 
10
- # Load Hugging Face token from environment variable
11
- HF_TOKEN = os.getenv("HF_TOKEN", os.environ['HF_TOKEN'])
12
-
13
- def get_dynamic_endpoint():
14
- """
15
- Fetch the dynamic endpoint using the Hugging Face API.
16
-
17
- Returns:
18
- str: The current dynamic endpoint.
19
- """
20
- try:
21
- api_url = "https://huggingface.co/api/spaces/duchaba/friendly-text-moderation"
22
- headers = {"Authorization": f"Bearer {HF_TOKEN}"}
23
-
24
- response = requests.get(api_url, headers=headers)
25
- response.raise_for_status() # Raise an error for bad status codes
26
-
27
- # Extract the endpoint from the response
28
- data = response.json()
29
- endpoint = data.get("url")
30
- return endpoint
31
- except Exception as e:
32
- print(f"Error fetching dynamic endpoint: {e}")
33
- return "https://default-endpoint.hf.space/--replicas/default/"
34
 
35
  # Fetch the dynamic endpoint
36
- dynamic_endpoint = get_dynamic_endpoint()
37
 
38
  # Initialize the client with the dynamic endpoint
39
  client = Client(dynamic_endpoint, hf_token=HF_TOKEN)
 
7
  from PIL import Image
8
  import base64
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
  # Fetch the dynamic endpoint
12
+ dynamic_endpoint = "https://duchaba-friendly-text-moderation.hf.space/api/predict"
13
 
14
  # Initialize the client with the dynamic endpoint
15
  client = Client(dynamic_endpoint, hf_token=HF_TOKEN)