fastapi-custom-model / request.py
gadkins
Add app
9abbe21
raw
history blame contribute delete
654 Bytes
import requests
import json
url = 'http://127.0.0.1:8000/generate'
headers = {
'accept': 'application/json',
'Content-Type': 'application/json',
}
data = {
"name": "Laptop",
"notes": "4GB RAM, 256 GB Disk"
}
response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.json())
# Check the status code of the response
# if response.status_code == 200:
# try:
# print(response.json())
# except json.decoder.JSONDecodeError:
# print("Response is not in JSON format.")
# else:
# print(f"Error: Received status code {response.status_code}")
# print("Response text:", response.text)