Spaces:
Sleeping
Sleeping
File size: 2,145 Bytes
9d76e23 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# import requests
# import json
# url = "https://sundaram22times-reco.hf.space/recommendations"
# params = {"query": "Food", "k": 5}
# headers = {"Accept": "application/json"} # Explicitly ask for JSON
# response = requests.get(url, params=params, headers=headers)
# print("Status Code:", response.status_code)
# print("Response:", response.json()) # Debug raw response
# #response = requests.get(...)
# json_data = json.loads(response.text)
# print("Parsed JSON Data:", json_data) # Print the parsed JSON data
# import requests
# import json
# url = "https://sundaram22times-reco.hf.space/recommendations"
# params = {"query": "Food", "k": 5}
# headers = {"Accept": "application/json"} # Ask for JSON explicitly
# response = requests.get(url, params=params, headers=headers)
# print("Status Code:", response.status_code)
# # Step 1: Print raw text to debug
# print("Raw Response Text:", repr(response.json()))
# # Step 2: Check if content is empty
# if not response.json():
# print("β οΈ Empty response body received.")
# else:
# try:
# json_data = response.json()
# print("β
Parsed JSON Data:", json_data)
# except json.JSONDecodeError as e:
# print("β JSON decode error:", e)
# print("Response content was:", repr(response.text))
import requests
import json
# Use the correct URL for your running FastAPI server
# If running locally, use:
# url = "http://localhost:8000/recommendations/"
# If deployed, use the deployed URL:
url = "https://sundaram22times-reco.hf.space/recommendations/" # Change this if needed
params = {"query": "Food", "k": 5}
headers = {"Accept": "application/json"} # Ask for JSON explicitly
response = requests.get(url, params=params, headers=headers)
print("Status Code:", response.status_code)
try:
# Try to parse JSON once
json_data = response.json()
print("β
Parsed JSON Data:", json_data)
except json.JSONDecodeError as e:
print("β JSON decode error:", e)
print("Raw Response Text:", repr(response.text))
except Exception as e:
print("β Unexpected error:", e)
print("Raw Response Text:", repr(response.text)) |