Skip to content

Commit 6b591e7

Browse files
committed
Update README.md with corrected curl command and improved Python example
Signed-off-by: Ankur-singh <[email protected]>
1 parent 5e638de commit 6b591e7

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

comps/guardrails/src/polite_guard/README.md

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ Once microservice starts, users can use examples (bash or python) below to apply
5656
**Bash:**
5757

5858
```bash
59-
curl localhost:9092/v1/polite
60-
-X POST
61-
-d '{"text":"He is stupid"}'
59+
curl localhost:9092/v1/polite \
60+
-X POST \
61+
-d '{"text":"He is stupid"}' \
6262
-H 'Content-Type: application/json'
6363
```
6464

@@ -72,18 +72,16 @@ Example Output:
7272

7373
```python
7474
import requests
75-
import json
7675

77-
proxies = {"http": ""}
76+
# Define the URL and payload
7877
url = "http://localhost:9092/v1/polite"
79-
data = {"text": "He is stupid"}
78+
payload = {"text": "He is stupid"}
79+
headers = {"Content-Type": "application/json"}
8080

81+
# Send a POST request
82+
response = requests.post(url, json=payload, headers=headers)
8183

82-
try:
83-
resp = requests.post(url=url, data=data, proxies=proxies)
84-
print(resp.text)
85-
resp.raise_for_status() # Raise an exception for unsuccessful HTTP status codes
86-
print("Request successful!")
87-
except requests.exceptions.RequestException as e:
88-
print("An error occurred:", e)
84+
# Print the response
85+
print("Status Code:", response.status_code)
86+
print("Response Body:", response.json())
8987
```

0 commit comments

Comments
 (0)