Spaces:
Sleeping
Sleeping
Create test_local.py
Browse files- test_local.py +20 -0
test_local.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import requests
|
| 2 |
+
import json
|
| 3 |
+
|
| 4 |
+
def test_local_api():
|
| 5 |
+
url = "http://localhost:7860/api/predict/"
|
| 6 |
+
|
| 7 |
+
test_data = {
|
| 8 |
+
"data": ["2025", "Paris", "Jazz Festival in the City Park", 0.8, 50]
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
try:
|
| 12 |
+
response = requests.post(url, json=test_data)
|
| 13 |
+
print("Status Code:", response.status_code)
|
| 14 |
+
print("Response:", response.json())
|
| 15 |
+
except Exception as e:
|
| 16 |
+
print("Error:", e)
|
| 17 |
+
print("Make sure your app is running on port 7860!")
|
| 18 |
+
|
| 19 |
+
if __name__ == "__main__":
|
| 20 |
+
test_local_api()
|