Spaces:
Sleeping
Sleeping
# 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)) |