Canstralian commited on
Commit
7ea3034
·
verified ·
1 Parent(s): d5d6495

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -15
app.py CHANGED
@@ -1,22 +1,22 @@
1
- import gradio as gr
2
 
3
- # Identifier of the Hugging Face Space
4
- space_url = "Canstralian/WhiteRabbitNeo"
5
 
6
- # Connect to the Space
7
- interface = gr.Interface.load(space_url)
8
 
9
- # Prompt to generate code and sentences
10
- prompt = "A new bug bounty to solve"
11
-
12
- # Get the generated result
13
  try:
14
- result = interface(prompt) # Ensure the interface supports string input and output
15
- print("Generated Result:", result)
16
-
 
 
 
 
 
17
  # Optionally, save the result to a text file
18
  with open("generated_output.txt", "w") as f:
19
- f.write(result)
20
-
21
- except Exception as e:
22
  print("An error occurred:", e)
 
1
+ import requests
2
 
3
+ # Replace with the correct Space API URL
4
+ api_url = "https://hf.space/embed/Canstralian/WhiteRabbitNeo/api/predict/"
5
 
6
+ # The input payload to send to the model
7
+ payload = {"data": ["A new bug bounty to solve"]}
8
 
 
 
 
 
9
  try:
10
+ # Make a POST request to the API
11
+ response = requests.post(api_url, json=payload)
12
+ response.raise_for_status() # Raise an exception for HTTP errors
13
+
14
+ # Parse the result
15
+ result = response.json() # Parse the JSON response from the API
16
+ print("Generated Result:", result["data"][0]) # Access the generated result
17
+
18
  # Optionally, save the result to a text file
19
  with open("generated_output.txt", "w") as f:
20
+ f.write(result["data"][0])
21
+ except requests.exceptions.RequestException as e:
 
22
  print("An error occurred:", e)