Spaces:
Sleeping
Sleeping
File size: 750 Bytes
dd7ff72 9dc4847 dd7ff72 | 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 | import requests
# Define the URL of the FastAPI server
url = "http://127.0.0.1:5000/chat/"
# Define the query you want to send
query = "Provide recent papers links or researches on brain tumors."
# Create the JSON payload
payload = {
"query": query
}
# Set the headers to specify JSON content
headers = {
"Content-Type": "application/json"
}
# Send the POST request
try:
response = requests.post(url, json=payload, headers=headers)
# Check if the request was successful
if response.status_code == 200:
print("Response from server:")
print(response.json())
else:
print(f"Error: {response.status_code}")
print(response.json())
except Exception as e:
print(f"An error occurred: {e}") |