Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,22 +1,22 @@
|
|
1 |
-
import
|
2 |
|
3 |
-
#
|
4 |
-
|
5 |
|
6 |
-
#
|
7 |
-
|
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 |
-
|
15 |
-
|
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)
|