File size: 654 Bytes
9abbe21
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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)